# IMPORTANT READ ME:
# R code for "Survey Methods 101" by Ozan Kuru
# these analyses are produced using "R 4.4.0 GUI 1.80 Big Sur ARM build" which is R 4.4.0 on a Macbook Pro
# ORGANIZATION: 
# 1) from start to until line 2280: data cleaning, computation of variables
# 2) line 4939: final reported version of main effects
# 3) line 6692: review process revision edits (includes additional models 2 and 3 in Table 2)
# 4) line 6813: bootstrap for intervention comparison
# 5) line 7767: final reported version of moderation tests
# there are many other appendix/robustness checks/additonal analyses about other exploratory and preregistered tests across the document, please read comments to navigate.

install.packages("foreign")
install.packages("weights")
install.packages("haven")
install.packages("MASS")
install.packages("car")
install.packages("ggplot2")
install.packages("readstata13")
#source("plotwtdinteraction.r")
install.packages("car")
install.packages("Matrix")
install.packages("mvtnorm")
install.packages("sandwich")
install.packages("mediation")
install.packages("gplots")
install.packages("DeclareDesign")
install.packages("DesignLibrary")
install.packages("sjPlot")
install.packages("sjmisc")
install.packages("ggpubr")
install.packages("psych")
install.packages("ltm")
install.packages("stargazer")
install.packages("wordcloud")
install.packages("wordcloud2")
install.packages("RColorBrewer")
install.packages("tm")
install.packages("vtable")
install.packages("rcompanion")
library(dplyr)
library(Matrix)
library(mvtnorm)
library(sandwich)
library(mediation)
library(foreign)
library(weights)
library(MASS)
library(car)
library(ggplot2)
library(foreign)
library(rcompanion)
library(gplots)
library(DeclareDesign)
library(DesignLibrary) 
library(sjPlot)
library(sjmisc)
library(ggpubr)
library(haven)
library(jtools)
library(ggplot2)
library(psych)
library(stargazer)
library(ltm)
library(wordcloud)
library(wordcloud2)
library(RColorBrewer)
library(tm)
library(vtable)

# read dataset 
library(haven)

d <- read_sav("Data.sav")
names(d)

# conditions
table(d$manips_w1)
table(d$manips_w2)

# remove 9 who appeared in W2 but cannot be found or matched in W1 initial survey (match ID failure)
# reported this in appendix
d <- d[d$manips_w1>0,] 

# dataset identifier: all vs. longitudinal effective sample
table(d$manips_w2) # 0 here are dropouts 
d$sample_indicator <-d$manips_w2
d$sample_indicator[d$sample_indicator>0] <- 1 # dummy where 1s participated in W2, while 0s are dropouts 
table(d$sample_indicator)

# speeders

# W1
describe(d$Duration__in_seconds_) #median 17 minutes for W1
# lowest possible time to complete W1 ranges from 220 to 283 seconds depending on which one of the 4 conditions respondent is in
describe(d$Duration__in_seconds_[d$Duration__in_seconds_<420]) # only 8 took W1 under 7 minutes *** REMOVE THESE speeders

#W2 
describe(d$W2_Duration__in_seconds_) #median 10 minutes for W2 (611 seconds)
# for all W2 respondents, lowest possible completion is 141 seconds
describe(d$W2_Duration__in_seconds_[d$W2_Duration__in_seconds_<180]) # nobody completed under 3 minutes
describe(d$W2_Duration__in_seconds_[d$W2_Duration__in_seconds_<240]) # nobody completed under 4 minutes, good
describe(d$W2_Duration__in_seconds_[d$W2_Duration__in_seconds_<300]) # only 8 completed under 5 minutes, but these cant be considered speeders, because it is short survey
# speeder issue is only for W1 since it involves training


# laggard for W2 exposure too long
# just overall survey completion observations:
describe(d$Duration__in_seconds_[d$Duration__in_seconds_>3600]) # observation, 158 respondents took more than 1 hour completing overall W1 survey, fine.
describe(d$W2_Duration__in_seconds_[d$W2_Duration__in_seconds_>3600]) # observation, 47 took more than 1 hour overall W2 survey
# lets focus on W2 exposure time lenght, minimum is 40 seconds
d$W2_timer13_Page_Submit #c1
d$W2_Q478_Page_Submit #c2
d$W2_Q482_Page_Submit #c3
d$W2_Q486_Page_Submit #c4
d$W2_Q490_Page_Submit #c5
d$W2_Q494_Page_Submit #c6
d$W2_Q498_Page_Submit #c7
d$W2_Q502_Page_Submit #c8

d$W2_s_c1<- d$W2_timer13_Page_Submit
d$W2_s_c2 <- d$W2_Q478_Page_Submit
d$W2_s_c3 <- d$W2_Q482_Page_Submit
d$W2_s_c4 <- d$W2_Q486_Page_Submit
d$W2_s_c5 <- d$W2_Q490_Page_Submit
d$W2_s_c6 <- d$W2_Q494_Page_Submit
d$W2_s_c7 <- d$W2_Q498_Page_Submit
d$W2_s_c8 <- d$W2_Q502_Page_Submit

d$W2_s_c1[is.na(d$W2_s_c1)] <- 0
d$W2_s_c2[is.na(d$W2_s_c2)] <- 0
d$W2_s_c3[is.na(d$W2_s_c3)] <- 0
d$W2_s_c4[is.na(d$W2_s_c4)] <- 0
d$W2_s_c5[is.na(d$W2_s_c5)] <- 0
d$W2_s_c6[is.na(d$W2_s_c6)] <- 0
d$W2_s_c7[is.na(d$W2_s_c7)] <- 0
d$W2_s_c8[is.na(d$W2_s_c8)] <- 0

d$W2_MessageExposuretime <- d$W2_s_c1+d$W2_s_c2+d$W2_s_c3+d$W2_s_c4+d$W2_s_c5+d$W2_s_c6+d$W2_s_c7+d$W2_s_c8
describe(d$W2_MessageExposuretime)
table(d$W2_MessageExposuretime)
table(d$W2_MessageExposuretime[d$W2_MessageExposuretime==0]) # includes dropputs, that is why median show 41 seconds while min time was 40 seconds for all

#lets remove dropouts to see real proportion of laggards
d$W2_MessageExposuretime_dropoutsRemoved <- d$W2_MessageExposuretime
#d$W2_MessageExposuretime_dropoutsRemoved[d$W2_MessageExposuretime_dropoutsRemoved==0] <- NA
#describe(d$W2_MessageExposuretime_dropoutsRemoved) # real median is 45 seconds
# but when we remove, it removes W1 droputs from data so we cant do attrition analysis etc.
# how about code 1 (min time was 3600 seconds anyway) to identify dropoout for laggard-removal purpose instead of removing them?
d$W2_MessageExposuretime_dropoutsRemoved[d$W2_MessageExposuretime_dropoutsRemoved==0] <- 1
describe(d$W2_MessageExposuretime_dropoutsRemoved)
# now lets identify potential laggards - those who spent a lot of time on exposure page:
describe(d$W2_MessageExposuretime_dropoutsRemoved[d$W2_MessageExposuretime_dropoutsRemoved>600]) # only 9 took more than 10 minutes
describe(d$W2_MessageExposuretime_dropoutsRemoved[d$W2_MessageExposuretime_dropoutsRemoved>900]) # only 5 took more than 15 minutes
describe(d$W2_MessageExposuretime_dropoutsRemoved[d$W2_MessageExposuretime_dropoutsRemoved>1200]) # 3 took more than 20 minutes DEFINETELY REMOVE THESE 3

## SUMMARY: WE WILL REMOVE 8 SPEEDERS IN W1 AND 3 LAGGARDS IN W2
# remove 8 W1 speeders:
d$Duration__in_seconds_[is.na(d$Duration__in_seconds_)] <- 1 # so that other half dataset is not excluded
summary(d$Duration__in_seconds_)
d <- d[d$Duration__in_seconds_>420,]
# remove the 3 laggards in W2 but do not use W2_MessageExposuretime_dropoutsRemoved for this, it removes dropputs, instead:
d <- d[d$W2_MessageExposuretime<1200,]





# remove DEBRIEF withdrawals, but you have to do this without deleting other wave's respondents:
table(d$debrief1) # 22 in W1
d <- d[d$debrief1==1,]

table(d$W2_debrief1) # 2 in W2 
summary(d$W2_debrief1)
# here too, we need to NA W1dropouts something first (say, 0) and include\retain them in new dataset being created that 
#excludes withdrawal requesting respondents
# withdrawals were coded as 2, so 1 and 0 will be included, so code 0 for dropouts:
d$W2_debrief1[is.na(d$W2_debrief1)] <- 1
table(d$W2_debrief1)
summary(d$W2_debrief1)
d <- d[d$W2_debrief1<2,]






# WAVE1

# equal\comparable cell Ns across conditions of W1 X W2 = 32 cells
table(d$manips_w1,d$manips_w2) # a bit heterogeneity, but Chisq show it is not significant, good:
# go to code line 1190 for the initialization of these factors first: manips_w1ff and manips_w2ff, and then test cell sample distribution:
chisq.test(d$manips_w1,d$manips_w2) 
# there was also no differential attrition based on W1 condition membership (e.g. control ...

# days between waves
table(d$EndDate)
table(d$W2_EndDate)
d$days<-as.Date(d$W2_EndDate)-as.Date(d$EndDate)
d$days<-as.numeric(d$days)
table(d$days)
describe(d$days)
hist(d$days)
summary(d$days)

# demogs
describe(d$Age)
summary(d$Age)
hist(d$Age)
d$Age_Years <- (d$Age-21)/58
table(d$Age_Years)
describe(d$Age_Years)
hist(d$Age_Years)

table(d$Sex_)
d$female <- d$Sex_
d$female[d$female==1] <- 0 #male
d$female[d$female==2] <- 1 #female
d$female[d$female==3] <- 0 #other (5 respondents) re-coded as male
table(d$female)
#describe(d$female)


# race, create Chinese majority var
table(d$RaceSG)
d$Chinese01 <-d$RaceSG
d$Chinese01[d$Chinese01>1] <-0
table(d$Chinese01)

#lets create 3 dummies with Chinese reference instead:
d$Malay<-d$RaceSG
table(d$Malay)
d$Malay[d$Malay==1] <- 0
d$Malay[d$Malay==3] <- 0
d$Malay[d$Malay==4] <- 0
d$Malay[d$Malay==2] <- 1
table(d$Malay)

d$Indian<-d$RaceSG
table(d$Indian)
d$Indian[d$Indian==1] <- 0
d$Indian[d$Indian==2] <- 0
d$Indian[d$Indian==4] <- 0
d$Indian[d$Indian==3] <- 1
table(d$Indian)

d$OtherRace<-d$RaceSG
table(d$OtherRace)
d$OtherRace[d$OtherRace==1] <- 0
d$OtherRace[d$OtherRace==2] <- 0
d$OtherRace[d$OtherRace==3] <- 0
d$OtherRace[d$OtherRace==4] <- 1
table(d$OtherRace)

# educat and educat01
table(d$EducationSG)
d$educat<-d$EducationSG
d$educat[d$educat<4] <- 1
d$educat[d$educat==4] <- 2
d$educat[d$educat==5] <- 2
d$educat[d$educat==6] <- 3
d$educat[d$educat>6] <- 4
table(d$educat)
hist(d$educat)
d$educat01 <- ((d$educat-1)/3) 
table(d$educat01)
describe(d$educat01)
# income
table(d$Income)
# impute median income for  do not want to responds
# first NA the dont responds so you get correct median
table(d$Income)
#describe(d$Income)
#describe(d$Income[(d$Income<14)])  #median is 5, excluding no response coded as 14
d$Income[d$Income==14] <- 5
table(d$Income)
d$Income01 <- ((d$Income-1)/11)
table(d$Income01)
hist(d$Income01)

# ideology, 2 versions
# we have 74 did not want to reply. can consider imputation to middle category which is also the mode, but that is problematic too.
# excluding no responses:
table(d$Ideology)
d$liberal<- d$Ideology
d$liberal[d$liberal==6] <- NA
d$liberal01<- ((d$liberal-1)/4)
table(d$liberal01)
# version that has no responses imputed as mid category which is also the substantively mode, so makes sense - USE THIS ONE IN CONTROL MODELS
d$liberalimputed <- d$Ideology
d$liberalimputed[d$liberalimputed==6] <- 3
table(d$liberalimputed)
d$liberalimputed01 <- ((d$liberalimputed-1)/4)
table(d$liberalimputed01)
describe(d$liberalimputed01)

# poll interest pretest
table(d$interest1)
table(d$interest2)
table(d$interest3)

dataframe_pretest_pollinterest_W1 <- data.frame(d$interest1,d$interest2, d$interest3)
alpha(dataframe_pretest_pollinterest_W1, na.rm = T)

d$interest1r <-(d$interest1-1)/4
d$interest2r <-(d$interest2-1)/4
d$interest3r <-(d$interest3-1)/4

d$pretest_INDEX_pollInterest_W1 <-(d$interest1r + d$interest2r + d$interest3r) / 3
table(d$pretest_INDEX_pollInterest_W1)
hist(d$pretest_INDEX_pollInterest_W1)
describe(d$pretest_INDEX_pollInterest_W1)

# pretest poll perceptions and beliefs - distinct, not a scale

table(d$pre_credible)   
d$pre_credible_01 <-(d$pre_credible-1)/4

table(d$pre_concern1)      
d$pre_concern1_01 <-(d$pre_concern1-1)/4

table(d$pre_efficacy1)  
d$pre_efficacy1_01 <-(d$pre_efficacy1-1)/4


# vaccine risk pretest

table(d$VaxRisk1)
table(d$VaxRisk2)
table(d$VaxRisk3)

d$pretest_vax_risk1_W1 <- d$VaxRisk1
d$pretest_vax_risk2_W1 <- d$VaxRisk2
d$pretest_vax_risk3_W1 <- d$VaxRisk3

dataframe_pretest_vax_risk_W1 <- data.frame(d$pretest_vax_risk1_W1,d$pretest_vax_risk2_W1, d$pretest_vax_risk3_W1)
alpha(dataframe_pretest_vax_risk_W1, na.rm = T)

d$pretest_vax_risk1x_W1 <-(d$pretest_vax_risk1_W1-1)/4
d$pretest_vax_risk2x_W1 <-(d$pretest_vax_risk2_W1-1)/4
d$pretest_vax_risk3x_W1 <-(d$pretest_vax_risk3_W1-1)/4

table(d$pretest_vax_risk1x_W1)
table(d$pretest_vax_risk2x_W1)
table(d$pretest_vax_risk3x_W1)

d$pretest_INDEX_vax_risk1_W1 <-(d$pretest_vax_risk1x_W1 + d$pretest_vax_risk2x_W1 + d$pretest_vax_risk3x_W1) / 3
table(d$pretest_INDEX_vax_risk1_W1)
hist(d$pretest_INDEX_vax_risk1_W1)
describe(d$pretest_INDEX_vax_risk1_W1)


# vaccine public opinion perception pretest 

describe(d$VaxPercept1)
describe(d$VaxPercept2)
describe(d$VaxPercept3)

d$pretest_vaxPO_risk1_W1 <- d$VaxPercept1
d$pretest_vaxPO_risk2_W1 <- d$VaxPercept2
d$pretest_vaxPO_risk3_W1 <- d$VaxPercept3

dataframe_pretest_vaxPO_risk_W1 <- data.frame(d$pretest_vaxPO_risk1_W1,d$pretest_vaxPO_risk2_W1, d$pretest_vaxPO_risk3_W1)
alpha(dataframe_pretest_vaxPO_risk_W1, na.rm = T)

d$pretest_vaxPO_risk1x_W1 <-(d$pretest_vaxPO_risk1_W1-1)/4
d$pretest_vaxPO_risk2x_W1 <-(d$pretest_vaxPO_risk2_W1-1)/4
d$pretest_vaxPO_risk3x_W1 <-(d$pretest_vaxPO_risk3_W1-1)/4

d$pretest_INDEX_vaxPO_risk1_W1 <-(d$pretest_vaxPO_risk1x_W1 + d$pretest_vaxPO_risk2x_W1 + d$pretest_vaxPO_risk3x_W1) / 3
table(d$pretest_INDEX_vaxPO_risk1_W1)
hist(d$pretest_INDEX_vaxPO_risk1_W1)
describe(d$pretest_INDEX_vaxPO_risk1_W1)

# additional vax pre_Test independent items

d$VaxPercept4 # percentage public opinion concerned about C19 vax
d$Vax_Intent # respondent intention of getting vaxxed
d$Vax_Overall # overall positivity towrds C19 vax

table(d$VaxPercept4)   
d$pre_VaxPerceptPOpercent_01 <-(d$VaxPercept4-1)/10 #higher value more percent people find risky
table(d$pre_VaxPerceptPOpercent_01)

table(d$Vax_Intent)      
d$pre_VaxIntention_01 <-(d$Vax_Intent-1)/6
table(d$pre_VaxIntention_01)

table(d$Vax_Overall)  
d$pre_Vax_Positivity_01 <-(d$Vax_Overall-1)/6
table(d$pre_Vax_Positivity_01)






# AI risk pretest

table(d$AI_Risk1)
table(d$AI_Risk2)
table(d$AI_Risk3)

d$pretest_AI_risk1_W1 <- d$AI_Risk1
d$pretest_AI_risk2_W1 <- d$AI_Risk2
d$pretest_AI_risk3_W1 <- d$AI_Risk3

dataframe_pretest_AI_risk_W1 <- data.frame(d$pretest_AI_risk1_W1,d$pretest_AI_risk2_W1, d$pretest_AI_risk3_W1)
alpha(dataframe_pretest_AI_risk_W1, na.rm = T)

d$pretest_AI_risk1x_W1 <-(d$pretest_AI_risk1_W1-1)/4
d$pretest_AI_risk2x_W1 <-(d$pretest_AI_risk2_W1-1)/4
d$pretest_AI_risk3x_W1 <-(d$pretest_AI_risk3_W1-1)/4

d$pretest_INDEX_AI_risk1_W1 <-(d$pretest_AI_risk1x_W1 + d$pretest_AI_risk2x_W1 + d$pretest_AI_risk3x_W1) / 3
table(d$pretest_INDEX_AI_risk1_W1)
hist(d$pretest_INDEX_AI_risk1_W1)
describe(d$pretest_INDEX_AI_risk1_W1)


# AI public opinion perception pretest 

table(d$AI_Percept1)
table(d$AI_Percept2)
table(d$AI_Percept3)

d$pretest_aiPO_risk1_W1 <- d$AI_Percept1
d$pretest_aiPO_risk2_W1 <- d$AI_Percept2
d$pretest_aiPO_risk3_W1 <- d$AI_Percept3


dataframe_pretest_aiPO_risk_W1 <- data.frame(d$pretest_aiPO_risk1_W1,d$pretest_aiPO_risk2_W1, d$pretest_aiPO_risk3_W1)
alpha(dataframe_pretest_aiPO_risk_W1, na.rm = T)

d$pretest_aiPO_risk1x_W1 <-(d$pretest_aiPO_risk1_W1-1)/4
d$pretest_aiPO_risk2x_W1 <-(d$pretest_aiPO_risk2_W1-1)/4
d$pretest_aiPO_risk3x_W1 <-(d$pretest_aiPO_risk3_W1-1)/4

d$pretest_INDEX_aiPO_risk1_W1 <-(d$pretest_aiPO_risk1x_W1 + d$pretest_aiPO_risk2x_W1 + d$pretest_aiPO_risk3x_W1) / 3
table(d$pretest_INDEX_aiPO_risk1_W1)
hist(d$pretest_INDEX_aiPO_risk1_W1)
describe(d$pretest_INDEX_aiPO_risk1_W1)

# additional vax pre_Test independent items

d$AI_Percept4  # percentage public opinion finding AI risky
d$AI_PolicyView  # respondent polciy view supporting regulation of ai
d$AI_Overall # overall positivity towrds C19 vax

table(d$AI_Percept4)   # 1 person missing response, 
d$pre_aiPerceptPOpercent_01 <-(d$AI_Percept4-1)/10 #higher value more percent people find risky , concerned about ai
table(d$pre_aiPerceptPOpercent_01)

table(d$AI_PolicyView)      
d$pre_AI_PolicyView_01 <-(d$AI_PolicyView-1)/6
table(d$pre_AI_PolicyView_01)

table(d$AI_Overall)  
d$pre_ai_Positivity_01 <-(d$AI_Overall-1)/6
table(d$pre_ai_Positivity_01)



# news literacy behavior
d$lit1_1 <- d$nlb1_1
d$lit1_2 <- d$nlb1_2
d$lit1_3 <- d$nlb1_3
d$lit2_1 <- d$nlb2_1
d$lit2_2 <- d$nlb2_2
d$lit2_3 <- d$nlb2_3
d$lit3_1 <- d$nlb3_1
d$lit3_2 <- d$nlb3_1
d$lit3_3 <- d$nlb3_1

d$pretest_NewsLit1_W1 <-(d$lit1_1-1)/4
d$pretest_NewsLit2_W1 <-(d$lit1_2-1)/4
d$pretest_NewsLit3_W1 <-(d$lit1_3-1)/4
d$pretest_NewsLit4_W1 <-(d$lit2_1-1)/4
d$pretest_NewsLit5_W1 <-(d$lit2_2-1)/4
d$pretest_NewsLit6_W1 <-(d$lit2_3-1)/4
d$pretest_NewsLit7_W1 <-(d$lit3_1-1)/4
d$pretest_NewsLit8_W1 <-(d$lit3_2-1)/4
d$pretest_NewsLit9_W1 <-(d$lit3_3-1)/4

dataframe_newslitbehave__W1 <- data.frame(d$pretest_NewsLit1_W1, d$pretest_NewsLit2_W1, d$pretest_NewsLit3_W1,
                                          d$pretest_NewsLit4_W1, d$pretest_NewsLit5_W1, d$pretest_NewsLit6_W1,
                                          d$pretest_NewsLit7_W1, d$pretest_NewsLit8_W1, d$pretest_NewsLit9_W1)
alpha(dataframe_newslitbehave__W1, na.rm = T)

d$index_NewsLitBehave_W1 <- (d$pretest_NewsLit1_W1 + d$pretest_NewsLit2_W1 + d$pretest_NewsLit3_W1 +
                               d$pretest_NewsLit4_W1 + d$pretest_NewsLit5_W1 + d$pretest_NewsLit6_W1 +
                               d$pretest_NewsLit7_W1 + d$pretest_NewsLit8_W1 + d$pretest_NewsLit9_W1) / 9

table(d$index_NewsLitBehave_W1)
hist(d$index_NewsLitBehave_W1)
describe(d$index_NewsLitBehave_W1)


# subjective numeracy scale
table(d$sn1)
d$sn1x <-(d$sn1-1)/4
d$sn2x <-(d$sn2-1)/4
d$sn3x <-(d$sn3-1)/4
d$sn4x <-(d$sn4-1)/4
d$sn5x <-(d$sn5-1)/4
d$sn6x <-(d$sn6-1)/4
d$sn7x <-(d$sn7-1)/4
d$sn8x <-(d$sn8-1)/4

dataframe_sn <- data.frame(d$sn1x,d$sn2x,d$sn3x,d$sn4x,d$sn5x,d$sn6x,d$sn7x,d$sn8x)
alpha(dataframe_sn, na.rm = T)

d$subjnum_W1 <- (d$sn1x+d$sn2x+d$sn3x+d$sn4x+d$sn5x+d$sn6x+d$sn7x+d$sn8x) / 8

table(d$subjnum_W1)
hist(d$subjnum_W1)
describe(d$subjnum_W1)


# scientific literacy
# made changes from original scale, we did not include the original scale's confusing items in our survey
# all correct answers are false
table(d$sl1)
# given that those who said true is coded 1, said false are coded 2, so we can determine accuracy of respondent by substracxting 1
# 1 is  respondent accurately determined statement as false, 0 is respondent inaccurately stated that statement is true

d$esl1<-d$sl1-1
d$esl2<-d$sl2-1
d$esl3<-d$sl3-1
d$esl4<-d$sl4-1
d$esl5<-d$sl5-1
d$esl6<-d$sl6-1
d$esl7<-d$sl7-1
d$esl8<-d$sl8-1

d$esl_total <- (d$esl1+d$esl2+d$esl3+d$esl4+d$esl5+
                  d$esl6+d$esl7+d$esl8)
dataframe_sl <- data.frame(d$esl1,d$esl2,d$esl3,d$esl4,d$esl5,
                             d$esl6,d$esl7,d$esl8)
alpha(dataframe_sl, na.rm = T)

table(d$esl_total)
d$esl_total01<-(d$esl_total/8)
table(d$esl_total01)
hist(d$esl_total01)


# in-built intervention questions for control, active literacy and inoculation conditions
# all correct responses are given with explanations to respondents in these conditions
### These also serve as MANIP CHECK to be discussed later in that section

# control in-built questionss
table(d$c1_baseballq1) # intention to play baseball
d$control_W1_inbuilt_IntentionBaseball <-(d$c1_baseballq1-1)/4
table(d$c1_baseballq2) # baseball is entertaining
d$control_W1_inbuilt_EntertainingBaseball <-(d$c1_baseballq2-1)/4

# passive literacy - no questions

# active literacy

table(d$c3_q01)
d$c3_q01x<-d$c3_q01
d$c3_q01x[d$c3_q01x==1] <-0
d$c3_q01x[d$c3_q01x==5] <-0
d$c3_q01x[d$c3_q01x==2] <-1
table(d$c3_q01x)

table(d$c3_q02)
d$c3_q02x<-d$c3_q02
d$c3_q02x[d$c3_q02x==1] <-0
d$c3_q02x[d$c3_q02x==3] <-0
d$c3_q02x[d$c3_q02x==2] <-1
table(d$c3_q02x)

table(d$c3_q03)
d$c3_q03x<-d$c3_q03
d$c3_q03x[d$c3_q03x==1] <-0
d$c3_q03x[d$c3_q03x==3] <-0
d$c3_q03x[d$c3_q03x==2] <-1
table(d$c3_q03x)

table(d$c3_q1)
d$c3_q1x<-d$c3_q1
d$c3_q1x[d$c3_q1x<6] <-0
d$c3_q1x[d$c3_q1x==6] <-1
table(d$c3_q1x)

table(d$c3_q2)
d$c3_q2x<-d$c3_q2
d$c3_q2x[d$c3_q2x<6] <-0
d$c3_q2x[d$c3_q2x==6] <-1
table(d$c3_q2x)

table(d$c3_q3)
d$c3_q3x<-d$c3_q3
d$c3_q3x[d$c3_q3x<5] <-0
d$c3_q3x[d$c3_q3x==5] <-1
d$c3_q3x[d$c3_q3x==6] <-0
table(d$c3_q3x)

d$c3_inbuilt_totalscore<-(d$c3_q01x + d$c3_q02x + d$c3_q03x + d$c3_q1x + d$c3_q2x + d$c3_q3x)
hist(d$c3_inbuilt_totalscore)
table(d$c3_inbuilt_totalscore)


# inoculation 

table(d$c4_q01)
d$c4_q01x<-d$c4_q01
d$c4_q01x[d$c4_q01x==1] <-0
d$c4_q01x[d$c4_q01x==5] <-0
d$c4_q01x[d$c4_q01x==2] <-1
table(d$c4_q01x)

table(d$c4_q02)
d$c4_q02x<-d$c4_q02
d$c4_q02x[d$c4_q02x==1] <-0
d$c4_q02x[d$c4_q02x==3] <-0
d$c4_q02x[d$c4_q02x==2] <-1
table(d$c4_q02x)

table(d$c4_q03)
d$c4_q03x<-d$c4_q03
d$c4_q03x[d$c4_q03x==1] <-0
d$c4_q03x[d$c4_q03x==3] <-0
d$c4_q03x[d$c4_q03x==2] <-1
table(d$c4_q03x)

table(d$c4_q1)
d$c4_q1x<-d$c4_q1
d$c4_q1x[d$c4_q1x<6] <-0
d$c4_q1x[d$c4_q1x==6] <-1
table(d$c4_q1x)

table(d$c4_q2)
d$c4_q2x<-d$c4_q2
d$c4_q2x[d$c4_q2x<6] <-0
d$c4_q2x[d$c4_q2x==6] <-1
table(d$c4_q2x)

table(d$c4_q3)
d$c4_q3x<-d$c4_q3
d$c4_q3x[d$c4_q3x<5] <-0
d$c4_q3x[d$c4_q3x==5] <-1
d$c4_q3x[d$c4_q3x==6] <-0
table(d$c4_q3x)

d$c4_inbuilt_totalscore<-(d$c4_q01x + d$c4_q02x + d$c4_q03x + d$c4_q1x + d$c4_q2x + d$c4_q3x)
hist(d$c4_inbuilt_totalscore)
table(d$c4_inbuilt_totalscore)



# W1 final control variables

# how many vaxs
table(d$vaccination)
d$numberofC19vax<-d$vaccination
d$numberofC19vax<-(d$numberofC19vax-1)/4
table(d$numberofC19vax)
# side effect
table(d$sideeffects)
d$sideEffectSeverity<-d$sideeffects
d$sideEffectSeverity<-(d$sideEffectSeverity-1)/4
table(d$sideEffectSeverity)
# AI experience
table(d$experienceAI)
d$experienceAI_01<-d$experienceAI
d$experienceAI_01<-(d$experienceAI_01-1)/4
table(d$experienceAI_01)



## manipulation check variables in W1 - WE NOT CONDUCT ANALYSIS YET, HERE ARE ALL W1 MANIP CHECKS:

table(d$b) # worried about misuse of polls INOCULATION
d$misinfo_polls_familiarity_W1_manipcheck <- d$b
d$misinfo_polls_familiarity_W1_manipcheck01 <- (d$misinfo_polls_familiarity_W1_manipcheck-1)/4
table(d$misinfo_polls_familiarity_W1_manipcheck01)

table(d$c) # twitter polls familiar INOCULATION
d$twitter_polls_familiarity_W1_manipcheck <- d$c
d$twitter_polls_familiarity_W1_manipcheck01 <- (d$twitter_polls_familiarity_W1_manipcheck-1)/4
table(d$twitter_polls_familiarity_W1_manipcheck01)

table(d$mc_for_control) # baseball CONTROL
d$informed_baseball_W1_manipcheck<-d$mc_for_control
d$informed_baseball_W1_manipcheck01 <- (d$informed_baseball_W1_manipcheck-1)/4
table(d$informed_baseball_W1_manipcheck01)

table(d$credible) # polls credibility in general item 1 ----- same as pretest, take diff score too: d$pre_credible_01 
d$poll_credible_W1post_manipcheck<-d$credible
d$poll_credible_W1post_manipcheck01 <-(d$poll_credible_W1post_manipcheck-1)/4
table(d$poll_credible_W1post_manipcheck01)
# diff score with pre-test
d$DIFF_W1post_W1pre_pollcredible <- d$poll_credible_W1post_manipcheck01 - d$pre_credible_01
table(d$DIFF_W1post_W1pre_pollcredible) # interventions created general skepticism but nnot necessarily inherently bad or good.

table(d$accurate) # polls credibility in general item 2
d$poll_accurate_W1post_manipcheck<-d$accurate
d$poll_accurate_W1post_manipcheck01 <-(d$poll_accurate_W1post_manipcheck-1)/4
table(d$poll_accurate_W1post_manipcheck01)

table(d$informative) # polls credibility in general item 3
d$poll_informative_W1post_manipcheck<-d$informative
d$poll_informative_W1post_manipcheck01 <-(d$poll_informative_W1post_manipcheck-1)/4
table(d$poll_informative_W1post_manipcheck01)

#index of credible, accurate, informative
d$index_pollcredibility_3items_W1posttest <- (d$poll_credible_W1post_manipcheck01 + d$poll_accurate_W1post_manipcheck01 +
                                                d$poll_informative_W1post_manipcheck01)/3
hist(d$index_pollcredibility_3items_W1posttest)

table(d$concern1) # polls misinfo-manipulation concern item 1 ----- same as pretest, take diff score too: d$pre_concern1_01  
d$poll_concern1_W1post <-d$concern1
d$poll_concern1_W1post01 <-(d$poll_concern1_W1post-1)/4
table(d$poll_concern1_W1post01)
# diff score from pre-test
d$DIFF_W1post_W1pre_pollconcern <- d$poll_concern1_W1post01 - d$pre_concern1_01
table(d$DIFF_W1post_W1pre_pollconcern) # concerns increased by end of W1, especially in inoculation

table(d$concern2) # polls misinfo-manipulation concern item 2
d$poll_concern2_W1post <-d$concern2
d$poll_concern2_W1post01 <-(d$poll_concern2_W1post-1)/4
table(d$poll_concern2_W1post01)

table(d$concern3) # polls misinfo-manipulation concern item 2
d$poll_concern3_W1post <-d$concern3
d$poll_concern3_W1post01 <-(d$poll_concern3_W1post-1)/4
table(d$poll_concern3_W1post01)

#indext of 3 poll concern posttest items in W1:
d$index_pollconcern3items_W1_posttest<-(d$poll_concern1_W1post01 + d$poll_concern2_W1post01 + d$poll_concern3_W1post01)/3
hist(d$index_pollconcern3items_W1_posttest)

table(d$efficacy1) # efficacy about polls item 1 ----- same as pretest, take diff score too: d$pre_efficacy1_01
d$poll_efficacy1_W1post <-d$efficacy1
d$poll_efficacy1_W1post01 <-(d$poll_efficacy1_W1post-1)/4
table(d$poll_efficacy1_W1post01)
# diff:
d$DIFF_W1post_W1pre_pollefficacy1 <- d$poll_efficacy1_W1post01 - d$pre_efficacy1_01
table(d$DIFF_W1post_W1pre_pollefficacy1) # interesting that efficacy dropped too after intervention! but this is overall, look by conditinos

table(d$efficacy2) # efficacy about polls item 2
d$poll_efficacy2_W1post <-d$efficacy2
d$poll_efficacy2_W1post01 <-(d$poll_efficacy2_W1post-1)/4
table(d$poll_efficacy2_W1post01)

#index of 2 poll efficacy W1 posttest items:
d$index_pollefficacy2items_W1_posttest<-(d$poll_efficacy1_W1post01 + d$poll_efficacy2_W1post01)/2
hist(d$index_pollefficacy2items_W1_posttest)












# W2 

# demographic consistency checks - looks good
table(d$W2_Age)
age_check <- lm(d$Age ~ d$W2_Age)
summary(age_check)

table(d$W2_RaceSG)
race_check <- lm(d$RaceSG ~ d$W2_RaceSG)
summary(race_check)

table(d$W2_Sex_)
sex_check <- lm(d$Sex_ ~ d$W2_Sex_)
summary(sex_check)




# pretest (W2) poll interest
# w2 crossectional:
d$interest1_w2<-d$W2_Q3
d$interest2_w2<-d$W2_Q4
d$interest3_w2<-d$W2_Q5

#describe(d$interest1_w2)
#describe(d$interest2_w2)
#describe(d$interest3_w2)

dataframe_pretest_pollinterest_W2 <- data.frame(d$interest1_w2,d$interest2_w2, d$interest3_w2)
alpha(dataframe_pretest_pollinterest_W2, na.rm = T)

d$interest1r_w2 <-(d$interest1_w2-1)/4
d$interest2r_w2 <-(d$interest2_w2-1)/4
d$interest3r_w2 <-(d$interest3_w2-1)/4

d$pretest_INDEX_pollInterest_W2 <-(d$interest1r_w2 + d$interest2r_w2 + d$interest3r_w2) / 3
table(d$pretest_INDEX_pollInterest_W2)
hist(d$pretest_INDEX_pollInterest_W2)
describe(d$pretest_INDEX_pollInterest_W2)

# W2 - W1 difference score (CAN BE CONSIDERED A LONGITUDINAL MANIPULATION CHECK TOO, BUT IT IS PRETEST...)
d$interest1r_w2minusw1 <-(d$interest1r_w2-d$interest1r)
d$interest2r_w2minusw1  <-(d$interest2r_w2-d$interest2r)
d$interest3r_w2minusw1  <-(d$interest3r_w2-d$interest3r)

table(d$interest1r_w2minusw1)
table(d$interest2r_w2minusw1)
table(d$interest3r_w2minusw1)

d$pretest_INDEX_pollInterest_w2minusw1 <-(d$interest1r_w2minusw1 + d$interest2r_w2minusw1 + d$interest3r_w2minusw1) / 3
table(d$pretest_INDEX_pollInterest_w2minusw1)
hist(d$pretest_INDEX_pollInterest_w2minusw1)
describe(d$pretest_INDEX_pollInterest_w2minusw1)

table(d$manips_w1,d$pretest_INDEX_pollInterest_w2minusw1)





# trust in science
# 3-item measure A

table(d$W2_TrustinScience_1)
table(d$W2_TrustinScience_2)
table(d$W2_TrustinScience_3)

d$trustscience_a1_W2 <-(d$W2_TrustinScience_1-1)/4
d$trustscience_a2_W2 <-(d$W2_TrustinScience_2-1)/4
d$trustscience_a3_W2 <-(d$W2_TrustinScience_3-1)/4

dataframe_pretest_trustinscinece_A_W2 <- data.frame(d$trustscience_a1_W2, d$trustscience_a2_W2, d$trustscience_a3_W2)
alpha(dataframe_pretest_trustinscinece_A_W2, na.rm = T)

d$index_trustinscinece_A_W2 <- (d$trustscience_a1_W2 + d$trustscience_a2_W2 + d$trustscience_a3_W2) / 3
table(d$index_trustinscinece_A_W2)
hist(d$index_trustinscinece_A_W2)
describe(d$index_trustinscinece_A_W2)

# 4-item measure B

table(d$W2_Q325_1)
table(d$W2_Q325_2)
table(d$W2_Q325_3)
table(d$W2_Q325_4)

d$trustscience_b1_W2 <-(d$W2_Q325_1-1)/4
d$trustscience_b2_W2 <-(d$W2_Q325_2-1)/4
d$trustscience_b3_W2 <-(d$W2_Q325_3-1)/4
d$trustscience_b4_W2 <-(d$W2_Q325_4-1)/4

dataframe_pretest_trustinscinece_B_W2 <- data.frame(d$trustscience_b1_W2, d$trustscience_b2_W2, 
                                                    d$trustscience_b3_W2, d$trustscience_b4_W2)
alpha(dataframe_pretest_trustinscinece_B_W2, na.rm = T)

d$index_trustinscinece_B_W2 <- (d$trustscience_b1_W2 + d$trustscience_b2_W2 +
                                  d$trustscience_b3_W2 + d$trustscience_b4_W2) / 4
table(d$index_trustinscinece_B_W2)
hist(d$index_trustinscinece_B_W2)
describe(d$index_trustinscinece_B_W2)



# DV1: poll credibility 

describe(d$W2_DVreliable)
describe(d$W2_DVaccurate)
describe(d$W2_DVvalid)
describe(d$W2_DVcredible)
describe(d$W2_DVscientific)

d$W2_DVreliable01 <-(d$W2_DVreliable-1)/4
d$W2_DVaccurate01 <-(d$W2_DVaccurate-1)/4
d$W2_DVvalid01 <-(d$W2_DVvalid-1)/4
d$W2_DVcredible01 <-(d$W2_DVcredible-1)/4
d$W2_DVscientific01 <-(d$W2_DVscientific-1)/4

# version 1 - excluding scientific item which was asked in second page 
dataframe_DVpollcred_W2 <- data.frame(d$W2_DVreliable01, d$W2_DVaccurate01, 
                                                    d$W2_DVvalid01, d$W2_DVcredible01)
alpha(dataframe_DVpollcred_W2, na.rm = T)

d$pollcred_DV_4 <- ((d$W2_DVreliable01 + d$W2_DVaccurate01 +
                    d$W2_DVvalid01 + d$W2_DVcredible01) / 4 ) 
table(d$pollcred_DV_4)
hist(d$pollcred_DV_4)
describe(d$pollcred_DV_4)


# version 2 - including scientific item too
dataframe_DVpollcred_W2b <- data.frame(d$W2_DVreliable01, d$W2_DVaccurate01, 
                                      d$W2_DVvalid01, d$W2_DVcredible01,d$W2_DVscientific01)
alpha(dataframe_DVpollcred_W2b, na.rm = T)

d$pollcred_DV_5 <- ((d$W2_DVreliable01 + d$W2_DVaccurate01 +
                       d$W2_DVvalid01 + d$W2_DVcredible01 + d$W2_DVscientific01) / 5 ) 
table(d$pollcred_DV_5)
hist(d$pollcred_DV_5)
describe(d$pollcred_DV_5)






# DV1: poll credibility - 2 versions (4 vs 5 item) - also do pooled analysis for this, but ai and vax outcomes (below listed ones) are only asked to those conditionns so cannot do pooled

# DV2: AI and Vaccine RISK (crossectional and diff scores): 3 items

# DV3: AI and Vaccine public opinion perceptions (crossectional and diff scores): 3 + 1 item

# DV4: AI and Vaccine intentions (crossectional and diff scores): 1 item

# DV5: AI and Vaccine general evaluations (crossectional and diff scores): 1 item






# Cross-sectional all:


# vaccine risk posttest

table(d$W2_VaxRisk1)
table(d$W2_VaxRisk2)
table(d$W2_VaxRisk3)

d$W2_posttest_vax_risk1_W2 <- d$W2_VaxRisk1
d$W2_posttest_vax_risk2_W2 <- d$W2_VaxRisk2
d$W2_posttest_vax_risk3_W2 <- d$W2_VaxRisk3

dataframe_posttest_vax_risk_W2 <- data.frame(d$W2_posttest_vax_risk1_W2,d$W2_posttest_vax_risk2_W2, d$W2_posttest_vax_risk3_W2)
dataframe_posttest_vax_risk_W2x<-na.omit(dataframe_posttest_vax_risk_W2)
alpha(dataframe_posttest_vax_risk_W2x, na.rm = F)
library(Cronbach)
cronbach(dataframe_posttest_vax_risk_W2x)

d$W2_posttest_vax_risk1x_W2 <-(d$W2_posttest_vax_risk1_W2-1)/4
d$W2_posttest_vax_risk2x_W2 <-(d$W2_posttest_vax_risk2_W2-1)/4
d$W2_posttest_vax_risk3x_W2 <-(d$W2_posttest_vax_risk3_W2-1)/4

table(d$W2_posttest_vax_risk1x_W2)
table(d$W2_posttest_vax_risk2x_W2)
table(d$W2_posttest_vax_risk3x_W2)

d$W2_posttest_INDEX_vax_risk1_W2 <-(d$W2_posttest_vax_risk1x_W2 + d$W2_posttest_vax_risk2x_W2 + d$W2_posttest_vax_risk3x_W2) / 3
table(d$W2_posttest_INDEX_vax_risk1_W2)
hist(d$W2_posttest_INDEX_vax_risk1_W2)
describe(d$W2_posttest_INDEX_vax_risk1_W2)


# vaccine public opinion perception posttest [INTERESTING TO LOOK AT SELF VS PUBLIC OPINION DIFF SCORES AS EXTRA ANALYSIS]

#describe(d$W2_VaxPercept1)
#describe(d$W2_VaxPercept2)
#describe(d$W2_VaxPercept3)

d$W2_posttest_vaxPO_risk1_W2 <- d$W2_VaxPercept1
d$W2_posttest_vaxPO_risk2_W2 <- d$W2_VaxPercept2
d$W2_posttest_vaxPO_risk3_W2 <- d$W2_VaxPercept3

dataframe_posttest_vaxPO_risk_W2 <- data.frame(d$W2_posttest_vaxPO_risk1_W2,d$W2_posttest_vaxPO_risk2_W2, d$W2_posttest_vaxPO_risk3_W2)
alpha(dataframe_posttest_vaxPO_risk_W2, na.rm = T)

d$W2_posttest_vaxPO_risk1x_W2 <-(d$W2_posttest_vaxPO_risk1_W2-1)/4
d$W2_posttest_vaxPO_risk2x_W2 <-(d$W2_posttest_vaxPO_risk2_W2-1)/4
d$W2_posttest_vaxPO_risk3x_W2 <-(d$W2_posttest_vaxPO_risk3_W2-1)/4

d$W2_posttest_INDEX_vaxPO_risk1_W2 <-(d$W2_posttest_vaxPO_risk1x_W2 + d$W2_posttest_vaxPO_risk2x_W2 + d$W2_posttest_vaxPO_risk3x_W2) / 3
table(d$W2_posttest_INDEX_vaxPO_risk1_W2)
hist(d$W2_posttest_INDEX_vaxPO_risk1_W2)
describe(d$W2_posttest_INDEX_vaxPO_risk1_W2)

# additional vax post_Test independent items

d$W2_VaxPercept4 # percentage public opinion concerned about C19 vax
d$W2_Vax_Intent # respondent intention of getting vaxxed
d$W2_Vax_Overall # overall positivity towrds C19 vax

table(d$W2_VaxPercept4)   
d$W2_post_VaxPerceptPOpercent_01 <-(d$W2_VaxPercept4-1)/10 #higher value more percent people find risky
table(d$W2_post_VaxPerceptPOpercent_01)
hist(d$W2_post_VaxPerceptPOpercent_01)

table(d$W2_Vax_Intent)      
d$W2_post_VaxIntention_01 <-(d$W2_Vax_Intent-1)/6
table(d$W2_post_VaxIntention_01)
hist(d$W2_post_VaxIntention_01)

table(d$W2_Vax_Overall)  
d$W2_post_Vax_Positivity_01 <-(d$W2_Vax_Overall-1)/6
table(d$W2_post_Vax_Positivity_01)
hist(d$W2_post_Vax_Positivity_01)







# AI risk posttest

table(d$W2_AI_Risk1)
table(d$W2_AI_Risk2)
table(d$W2_AI_Risk3)

d$W2_posttest_AI_risk1_W2 <- d$W2_AI_Risk1
d$W2_posttest_AI_risk2_W2 <- d$W2_AI_Risk2
d$W2_posttest_AI_risk3_W2 <- d$W2_AI_Risk3

dataframe_posttest_AI_risk_W2 <- data.frame(d$W2_posttest_AI_risk1_W2,d$W2_posttest_AI_risk2_W2, d$W2_posttest_AI_risk3_W2)
alpha(dataframe_posttest_AI_risk_W2, na.rm = T)

d$W2_posttest_AI_risk1x_W2 <-(d$W2_posttest_AI_risk1_W2-1)/4
d$W2_posttest_AI_risk2x_W2 <-(d$W2_posttest_AI_risk2_W2-1)/4
d$W2_posttest_AI_risk3x_W2 <-(d$W2_posttest_AI_risk3_W2-1)/4

d$W2_posttest_INDEX_AI_risk1_W2 <-(d$W2_posttest_AI_risk1x_W2 + d$W2_posttest_AI_risk2x_W2 + d$W2_posttest_AI_risk3x_W2) / 3
table(d$W2_posttest_INDEX_AI_risk1_W2)
hist(d$W2_posttest_INDEX_AI_risk1_W2)
describe(d$W2_posttest_INDEX_AI_risk1_W2)


# AI public opinion perception posttest 

table(d$W2_AI_Percept1)
table(d$W2_AI_Percept2)
table(d$W2_AI_Percept3)


d$W2_posttest_aiPO_risk1_W2 <- d$W2_AI_Percept1
d$W2_posttest_aiPO_risk2_W2 <- d$W2_AI_Percept2
d$W2_posttest_aiPO_risk3_W2 <- d$W2_AI_Percept3

dataframe_posttest_aiPO_risk_W2 <- data.frame(d$W2_posttest_aiPO_risk1_W2,d$W2_posttest_aiPO_risk2_W2, d$W2_posttest_aiPO_risk3_W2)
alpha(dataframe_posttest_aiPO_risk_W2, na.rm = T)

d$W2_posttest_aiPO_risk1x_W2 <-(d$W2_posttest_aiPO_risk1_W2-1)/4
d$W2_posttest_aiPO_risk2x_W2 <-(d$W2_posttest_aiPO_risk2_W2-1)/4
d$W2_posttest_aiPO_risk3x_W2 <-(d$W2_posttest_aiPO_risk3_W2-1)/4

d$W2_posttest_INDEX_aiPO_risk1_W2 <-(d$W2_posttest_aiPO_risk1x_W2 + d$W2_posttest_aiPO_risk2x_W2 + d$W2_posttest_aiPO_risk3x_W2) / 3
table(d$W2_posttest_INDEX_aiPO_risk1_W2)
hist(d$W2_posttest_INDEX_aiPO_risk1_W2)
describe(d$W2_posttest_INDEX_aiPO_risk1_W2)

# additional vax post_Test independent items

d$W2_AI_Percept4  # percentage public opinion concerned about C19 vax
d$W2_AI_PolicyView  # respondent polciy view supporting regulation of ai
d$W2_AI_Overall # overall positivity towrds C19 vax

table(d$W2_AI_Percept4)   # 1 person missing response, 
d$W2_post_aiPerceptPOpercent_01 <-(d$W2_AI_Percept4-1)/10 #higher value more percent people find risky , concerned about ai
table(d$W2_post_aiPerceptPOpercent_01)
hist(d$W2_post_aiPerceptPOpercent_01)

table(d$W2_AI_PolicyView)      
d$W2_post_AI_PolicyView_01 <-(d$W2_AI_PolicyView-1)/6
table(d$W2_post_AI_PolicyView_01)
hist(d$W2_post_AI_PolicyView_01)

table(d$W2_AI_Overall)  
d$W2_post_ai_Positivity_01 <-(d$W2_AI_Overall-1)/6
table(d$W2_post_ai_Positivity_01)
hist(d$W2_post_ai_Positivity_01)





### diff scores for dvs all:

# list all cross-sectionals first
#DVs W2:
d$W2_posttest_INDEX_vax_risk1_W2
d$W2_posttest_INDEX_vaxPO_risk1_W2
d$W2_post_VaxPerceptPOpercent_01
d$W2_post_VaxIntention_01
d$W2_post_Vax_Positivity_01

d$W2_posttest_INDEX_AI_risk1_W2
d$W2_posttest_INDEX_aiPO_risk1_W2
d$W2_post_aiPerceptPOpercent_01
d$W2_post_AI_PolicyView_01
d$W2_post_ai_Positivity_01
# pretests W1
d$pretest_INDEX_vax_risk1_W1 
d$pretest_INDEX_vaxPO_risk1_W1 
d$pre_VaxPerceptPOpercent_01     
d$pre_VaxIntention_01
d$pre_Vax_Positivity_01 

d$pretest_INDEX_AI_risk1_W1
d$pretest_INDEX_aiPO_risk1_W1
d$pre_aiPerceptPOpercent_01 
d$pre_AI_PolicyView_01 
d$pre_ai_Positivity_01

# W2 minus W1 diffs:
d$DIFFw2w1_INDEX_vax_risk1 <- d$W2_posttest_INDEX_vax_risk1_W2 - d$pretest_INDEX_vax_risk1_W1 
d$DIFFw2w1_INDEX_vaxPO_risk1 <- d$W2_posttest_INDEX_vaxPO_risk1_W2 - d$pretest_INDEX_vaxPO_risk1_W1 
d$DIFFw2w1_VaxPerceptPOpercent <- d$W2_post_VaxPerceptPOpercent_01 - d$pre_VaxPerceptPOpercent_01  
d$DIFFw2w1_VaxIntention <- d$W2_post_VaxIntention_01 - d$pre_VaxIntention_01
d$DIFFw2w1_Vax_Positivity <- d$W2_post_Vax_Positivity_01 - d$pre_Vax_Positivity_01 

d$DIFFw2w1_INDEX_AI_risk1 <- d$W2_posttest_INDEX_AI_risk1_W2 - d$pretest_INDEX_AI_risk1_W1
d$DIFFw2w1_INDEX_aiPO_risk1 <- d$W2_posttest_INDEX_aiPO_risk1_W2 - d$pretest_INDEX_aiPO_risk1_W1
d$DIFFw2w1_aiPerceptPOpercent_01 <- d$W2_post_aiPerceptPOpercent_01 - d$pre_aiPerceptPOpercent_01 
d$DIFFw2w1_AI_PolicyView_01 <- d$W2_post_AI_PolicyView_01 - d$pre_AI_PolicyView_01 
d$DIFFw2w1_ai_Positivity_01 <- d$W2_post_ai_Positivity_01 - d$pre_ai_Positivity_01

hist(d$DIFFw2w1_INDEX_vax_risk1)
hist(d$DIFFw2w1_INDEX_vaxPO_risk1)
hist(d$DIFFw2w1_VaxPerceptPOpercent)
hist(d$DIFFw2w1_VaxIntention)
hist(d$DIFFw2w1_Vax_Positivity)
hist(d$DIFFw2w1_INDEX_AI_risk1)
hist(d$DIFFw2w1_INDEX_aiPO_risk1)
hist(d$DIFFw2w1_aiPerceptPOpercent_01)
hist(d$DIFFw2w1_AI_PolicyView_01)
hist(d$DIFFw2w1_ai_Positivity_01)

#media - got news and info from the following:
table(d$W2_media1_1) # print newspaper
table(d$W2_media1_2) # tv news
table(d$W2_media1_3) # online news
table(d$W2_media1_4) # facebook
table(d$W2_media1_5) # twitter
table(d$W2_media1_6) # whatsapp
table(d$W2_media1_7) # telegram
table(d$W2_media1_8) # instagram
table(d$W2_media1_9) # youtube

d$W2_NewsExp_PrintPaper_W1 <-(d$W2_media1_1-1)/8
d$W2_NewsExp_TV_W1 <-(d$W2_media1_2-1)/8
d$W2_NewsExp_OnlineNews_W1 <-(d$W2_media1_3-1)/8
d$W2_NewsExp_Facebook_W1 <-(d$W2_media1_4-1)/8
d$W2_NewsExp_Twitter_W1 <-(d$W2_media1_5-1)/8
d$W2_NewsExp_Whatsapp_W1 <-(d$W2_media1_6-1)/8
d$W2_NewsExp_Telegram_W1 <-(d$W2_media1_7-1)/8
d$W2_NewsExp_Instagram_W1 <-(d$W2_media1_8-1)/8
d$W2_NewsExp_Youtube_W1 <-(d$W2_media1_9-1)/8

# trad news exposure
# low reliability
#but low reliability not a problem since this is overall trad news reliance metric
dataframe_tradnews__W1 <- data.frame(d$W2_NewsExp_PrintPaper_W1, d$W2_NewsExp_TV_W1,
                                     d$W2_NewsExp_OnlineNews_W1)
alpha(dataframe_tradnews__W1, na.rm = T)

d$W2_index_TradNews_W1 <- (d$W2_NewsExp_PrintPaper_W1 + d$W2_NewsExp_TV_W1 + d$W2_NewsExp_OnlineNews_W1) / 3
table(d$W2_index_TradNews_W1)
hist(d$W2_index_TradNews_W1)
describe(d$W2_index_TradNews_W1)

# social media news exposure
dataframe_SocialNews__W1 <- data.frame(d$W2_NewsExp_Facebook_W1, d$W2_NewsExp_Twitter_W1,
                                       d$W2_NewsExp_Instagram_W1, d$W2_NewsExp_Youtube_W1)
alpha(dataframe_SocialNews__W1, na.rm = T)

d$W2_index_SocialNews_W1 <- (d$W2_NewsExp_Facebook_W1 + d$W2_NewsExp_Twitter_W1 +
                               d$W2_NewsExp_Instagram_W1 + d$W2_NewsExp_Youtube_W1) / 4
table(d$W2_index_SocialNews_W1)
hist(d$W2_index_SocialNews_W1)
describe(d$W2_index_SocialNews_W1)

# messaging application news

dataframe_MessAppNews__W1 <- data.frame(d$W2_NewsExp_Whatsapp_W1, d$W2_NewsExp_Telegram_W1)
alpha(dataframe_MessAppNews__W1, na.rm = T)


d$W2_index_MessAppNews_W1 <- (d$W2_NewsExp_Whatsapp_W1 + d$W2_NewsExp_Telegram_W1) / 2
table(d$W2_index_MessAppNews_W1)
hist(d$W2_index_MessAppNews_W1)
describe(d$W2_index_MessAppNews_W1)




# interference measures

table(d$W2_int1) # poll
d$interfere_poll <-(d$W2_int1-1)/5
table(d$interfere_poll)

table(d$W2_int2) # vax
d$interfere_vax <-(d$W2_int2-1)/5
table(d$interfere_vax)

table(d$W2_int3) # AI
d$interfere_ai <-(d$W2_int3-1)/5
table(d$interfere_ai)




## manipulation factors in W2: low-high, pro-anti, covid vs. ai

# WAVE 1 FACTORS:

# MANIP FACTOR 1) conditions as a factor of 4 arms
table(d$manips_w1)
d$manips_w1f <- d$manips_w1
d$manips_w1f[d$manips_w1f==1] <- "Control (W1)"
d$manips_w1f[d$manips_w1f==2] <- "Int1: Passive Literacy (W1)"
d$manips_w1f[d$manips_w1f==3] <- "Int2: Active Literacy (W1)"
d$manips_w1f[d$manips_w1f==4] <- "Int3: Inoculation (W1)"
table(d$manips_w1f)
# reorder
d$manips_w1ff <- factor(d$manips_w1f, levels = c("Control (W1)", "Int1: Passive Literacy (W1)", 
                                                 "Int2: Active Literacy (W1)", "Int3: Inoculation (W1)"))
table(d$manips_w1ff)
is.factor(d$manips_w1ff)

# MANIP FACTOR 2) control vs. all interventions combined
table(d$manips_w1)
d$manips_w1_C1vsC234 <- d$manips_w1
d$manips_w1_C1vsC234[d$manips_w1_C1vsC234==1] <- 0
d$manips_w1_C1vsC234[d$manips_w1_C1vsC234>1] <- 1
table(d$manips_w1_C1vsC234)

# MANIP FACTOR 3) control vs. both literacy combined vs. inoculation
table(d$manips_w1)
d$manips_w1_C1vsC23vsC4 <- d$manips_w1
d$manips_w1_C1vsC23vsC4[d$manips_w1_C1vsC23vsC4==1] <- 1
d$manips_w1_C1vsC23vsC4[d$manips_w1_C1vsC23vsC4==2] <- 2
d$manips_w1_C1vsC23vsC4[d$manips_w1_C1vsC23vsC4==3] <- 2
d$manips_w1_C1vsC23vsC4[d$manips_w1_C1vsC23vsC4==4] <- 3
table(d$manips_w1_C1vsC23vsC4)
d$manips_w1_C1vsC23vsC4[d$manips_w1_C1vsC23vsC4==1] <- "Control (W1)"
d$manips_w1_C1vsC23vsC4[d$manips_w1_C1vsC23vsC4==2] <- "Literacy (Int1&2) Combined (W1)"
d$manips_w1_C1vsC23vsC4[d$manips_w1_C1vsC23vsC4==3] <- "Int3: Inoculation (W1)"
table(d$manips_w1_C1vsC23vsC4)

# MANIP FACTOR 4) control vs. passive literacy  vs. active literacy + inoculation combined
table(d$manips_w1)
d$manips_w1_C1vsC2vsC34 <- d$manips_w1
d$manips_w1_C1vsC2vsC34[d$manips_w1_C1vsC2vsC34==1] <- 1
d$manips_w1_C1vsC2vsC34[d$manips_w1_C1vsC2vsC34==2] <- 2
d$manips_w1_C1vsC2vsC34[d$manips_w1_C1vsC2vsC34==3] <- 3
d$manips_w1_C1vsC2vsC34[d$manips_w1_C1vsC2vsC34==4] <- 3
table(d$manips_w1_C1vsC2vsC34)
d$manips_w1_C1vsC2vsC34[d$manips_w1_C1vsC2vsC34==1] <- "Control (W1)"
d$manips_w1_C1vsC2vsC34[d$manips_w1_C1vsC2vsC34==2] <- "Int1: PassiveLiteracy (W1)"
d$manips_w1_C1vsC2vsC34[d$manips_w1_C1vsC2vsC34==3] <- "Int2 & Inoculation Combined (W1)"
table(d$manips_w1_C1vsC2vsC34)

# WAVE 2 FACTORS

table(d$manips_w2)
d$manips_w2f<-d$manips_w2
d$manips_w2f[d$manips_w2f==1] <- "Low,Concern,C19"
d$manips_w2f[d$manips_w2f==2] <- "High,Concern,C19"
d$manips_w2f[d$manips_w2f==3] <- "Low,Confident,C19"
d$manips_w2f[d$manips_w2f==4] <- "High,Confident,C19"
d$manips_w2f[d$manips_w2f==5] <- "Low,Support,AI"
d$manips_w2f[d$manips_w2f==6] <- "High,Support,AI"
d$manips_w2f[d$manips_w2f==7] <- "Low,Oppose,AI"
d$manips_w2f[d$manips_w2f==8] <- "High,Oppose,AI"
table(d$manips_w2f)
d$manips_w2ff<-d$manips_w2f
d$manips_w2ff <- factor(d$manips_w2ff, levels = c("Low,Concern,C19","High,Concern,C19",
                                                  "Low,Confident,C19","High,Confident,C19",
                                                  "Low,Support,AI","High,Support,AI",
                                                  "Low,Oppose,AI","High,Oppose,AI"))
table(d$manips_w2ff)

# low vs high quality
d$manips_W2_lowVshighQuality <- d$manips_w2
d$manips_W2_lowVshighQuality[d$manips_W2_lowVshighQuality==1] <- "Low Quality"
d$manips_W2_lowVshighQuality[d$manips_W2_lowVshighQuality==2] <- "High Quality"
d$manips_W2_lowVshighQuality[d$manips_W2_lowVshighQuality==3] <- "Low Quality"
d$manips_W2_lowVshighQuality[d$manips_W2_lowVshighQuality==4] <- "High Quality"
d$manips_W2_lowVshighQuality[d$manips_W2_lowVshighQuality==5] <- "Low Quality"
d$manips_W2_lowVshighQuality[d$manips_W2_lowVshighQuality==6] <- "High Quality"
d$manips_W2_lowVshighQuality[d$manips_W2_lowVshighQuality==7] <- "Low Quality"
d$manips_W2_lowVshighQuality[d$manips_W2_lowVshighQuality==8] <- "High Quality"
table(d$manips_W2_lowVshighQuality)
d$manips_W2_lowVshighQuality <- factor(d$manips_W2_lowVshighQuality, levels = c("Low Quality", "High Quality"))
table(d$manips_W2_lowVshighQuality)

# covid vax vs AI
table(d$manips_w2)
d$manips_W2_covidVsAI <- d$manips_w2
table(d$manips_W2_covidVsAI)
d$manips_W2_covidVsAI[d$manips_W2_covidVsAI==0] <- NA
d$manips_W2_covidVsAI[d$manips_W2_covidVsAI>4] <- "AI Regulation Policy"
d$manips_W2_covidVsAI[d$manips_W2_covidVsAI<5] <- "C-19 Vaccine Concern"
table(d$manips_W2_covidVsAI)
d$manips_W2_covidVsAI <- factor(d$manips_W2_covidVsAI, levels = c("C-19 Vaccine Concern", "AI Regulation Policy"))
table(d$manips_W2_covidVsAI)

# we cannot combine  concern\confident and support\oppose into single factor, does not make sense; these are to 
#be tested separately only, not pooled like poll cred; they are very different topics:covid vs ai AND belief dimension differ: concern vs support.


# concern vs. confident vax
d$manips_W2_covid_ConcernVsConfident <- d$manips_w2
d$manips_W2_covid_ConcernVsConfident[d$manips_W2_covid_ConcernVsConfident ==0] <- NA
d$manips_W2_covid_ConcernVsConfident[d$manips_W2_covid_ConcernVsConfident > 4] <- NA
d$manips_W2_covid_ConcernVsConfident[d$manips_W2_covid_ConcernVsConfident==1] <-"Concerned about Vaccine"
d$manips_W2_covid_ConcernVsConfident[d$manips_W2_covid_ConcernVsConfident==2] <-"Concerned about Vaccine"
d$manips_W2_covid_ConcernVsConfident[d$manips_W2_covid_ConcernVsConfident==3] <-"Confident about Vaccine"
d$manips_W2_covid_ConcernVsConfident[d$manips_W2_covid_ConcernVsConfident==4] <-"Confident about Vaccine"
table(d$manips_W2_covid_ConcernVsConfident)

# support vs. oppose AI regulation
d$manips_W2_AIregulation_SupportVsOppose <- d$manips_w2
d$manips_W2_AIregulation_SupportVsOppose[d$manips_W2_AIregulation_SupportVsOppose ==0] <- NA
d$manips_W2_AIregulation_SupportVsOppose[d$manips_W2_AIregulation_SupportVsOppose < 5] <- NA
d$manips_W2_AIregulation_SupportVsOppose[d$manips_W2_AIregulation_SupportVsOppose==5] <- "Support AI-Regulation"
d$manips_W2_AIregulation_SupportVsOppose[d$manips_W2_AIregulation_SupportVsOppose==6] <- "Support AI-Regulation"
d$manips_W2_AIregulation_SupportVsOppose[d$manips_W2_AIregulation_SupportVsOppose==7] <- "Oppose AI-Regulation"
d$manips_W2_AIregulation_SupportVsOppose[d$manips_W2_AIregulation_SupportVsOppose==8] <- "Oppose AI-Regulation"
table(d$manips_W2_AIregulation_SupportVsOppose)





d$pretest_INDEX_vax_risk1_W1



# for unfavorable and unexpected codings below (BASED ON MESSAGE POLL RESULT), 
# we use some pre-tests both as a IV factor component as coded here, so when using those,
# we should NOT USE those same questions as part of difference score DVs 

# unfavorable outcome factor based on pre-existing views
# respondent pretest positions
# vax: pretest second item: how concerned are you  
table(d$pretest_vax_risk2x_W1)
#AI: pretest second item: how concerned are you  
table(d$pretest_AI_risk2x_W1)

# turn the poll-result manipulation factors to numeric and 0vs1 coding then before combining the manipulation and respondent character variables
table(d$manips_W2_covid_ConcernVsConfident)
d$manips_W2_covid_ConcernVsConfident_num<-d$manips_W2_covid_ConcernVsConfident
d$manips_W2_covid_ConcernVsConfident_num[d$manips_W2_covid_ConcernVsConfident_num=="Concerned about Vaccine"] <- 1
d$manips_W2_covid_ConcernVsConfident_num[d$manips_W2_covid_ConcernVsConfident_num=="Confident about Vaccine"] <- 0
table(d$manips_W2_covid_ConcernVsConfident_num) # 1 is concerned, 0 is confident
d$manips_W2_covid_ConcernVsConfident_num <- as.numeric(d$manips_W2_covid_ConcernVsConfident_num)
table(d$manips_W2_covid_ConcernVsConfident_num)
summary(d$manips_W2_covid_ConcernVsConfident_num)

table(d$manips_W2_AIregulation_SupportVsOppose)
d$manips_W2_AIregulation_SupportVsOppose_num<-d$manips_W2_AIregulation_SupportVsOppose
d$manips_W2_AIregulation_SupportVsOppose_num[d$manips_W2_AIregulation_SupportVsOppose_num=="Support AI-Regulation"] <-1
d$manips_W2_AIregulation_SupportVsOppose_num[d$manips_W2_AIregulation_SupportVsOppose_num=="Oppose AI-Regulation"] <-0
table(d$manips_W2_AIregulation_SupportVsOppose_num)
d$manips_W2_AIregulation_SupportVsOppose_num<-as.numeric(d$manips_W2_AIregulation_SupportVsOppose_num)
table(d$manips_W2_AIregulation_SupportVsOppose_num)
summary(d$manips_W2_AIregulation_SupportVsOppose_num)



# BASED ON PERSON'S OWN RISK PERCEPTIONS PRETEST SCORE
# vax unfavorable poll result
table(d$pretest_vax_risk2x_W1) # higher value more risk
table(d$manips_W2_covid_ConcernVsConfident_num) # 1 is concerned

# given poll result 0=majority confident, 1=majority concerned, to create an unfavorable\personal belief-Public opinion 
# inconsistent result, we need to create a variable where those who seen poll=1 risky are reverse coded and the risk values 
# of those who seen poll=0=confident are kept same, these two portions are then combined into single variable.

table(d[d$manips_W2_covid_ConcernVsConfident_num==0,]$pretest_vax_risk2x_W1) #poll: confident
table(d[d$manips_W2_covid_ConcernVsConfident_num==1,]$pretest_vax_risk2x_W1) # poll: concerned

# we can do this easier, by first substracting attitudes from manip factor and then recode that distribution 
#(folding the bipolar distribution of extremity(most unfavored) at end)

d$RseenAttitudeInconsistentPO_vaxrisk <- d$manips_W2_covid_ConcernVsConfident_num - d$pretest_vax_risk2x_W1 
table(d$RseenAttitudeInconsistentPO_vaxrisk) 
# turn all negatives to positives basically:
d$RseenAttitudeInconsistentPO_vaxrisk_absolute <- abs(d$RseenAttitudeInconsistentPO_vaxrisk)
table(d$RseenAttitudeInconsistentPO_vaxrisk_absolute)

# do same for AI part:
# ai unfavorable poll result
table(d$pretest_AI_risk2x_W1)
table(d$manips_W2_AIregulation_SupportVsOppose_num)

table(d[d$manips_W2_AIregulation_SupportVsOppose_num==0,]$pretest_AI_risk2x_W1) # poll: oppose AI regulation
table(d[d$manips_W2_AIregulation_SupportVsOppose_num==1,]$pretest_AI_risk2x_W1) # poll: support AI regulation

d$RseenAttitudeInconsistentPO_AIrisk <- d$manips_W2_AIregulation_SupportVsOppose_num - d$pretest_AI_risk2x_W1 
table(d$RseenAttitudeInconsistentPO_AIrisk)

d$RseenAttitudeInconsistentPO_AIrisk_absolute <- abs(d$RseenAttitudeInconsistentPO_AIrisk)
table(d$RseenAttitudeInconsistentPO_AIrisk_absolute)




# appendix for AI issue alternative variable
# BASED ON PERSON'S AIpolciyView questions
table(d$pre_AI_PolicyView_01)
table(d[d$manips_W2_AIregulation_SupportVsOppose_num==0,]$pre_AI_PolicyView_01) # poll: oppose AI regulation
table(d[d$manips_W2_AIregulation_SupportVsOppose_num==1,]$pre_AI_PolicyView_01) # poll: support AI regulation
d$RseenAttitudeInconsistentPO_aiPolicy <- d$manips_W2_AIregulation_SupportVsOppose_num - d$pre_AI_PolicyView_01 
table(d$RseenAttitudeInconsistentPO_aiPolicy)
d$RseenAttitudeInconsistentPO_aiPolicy_absolute <- abs(d$RseenAttitudeInconsistentPO_aiPolicy)
table(d$RseenAttitudeInconsistentPO_aiPolicy_absolute)







# W2 MANIP CHECK variables

# 1) first set list
table(d$W2_mc1)
table(d$W2_mc2a1)
table(d$W2_mc2b1)
table(d$W2_mc2xa1)
table(d$W2_mc2xa2)
table(d$W2_mc2xb1)
table(d$W2_mc2xb2)
table(d$W2_mc2a2)
table(d$W2_mc2b2)

# 2) second set list:  quiz performance
table(d$W2_c) 
table(d$W2_d)
table(d$W2_a)

table(d$W2_c)
d$W2_cx<-d$W2_c
d$W2_cx[d$W2_cx<5] <-0
d$W2_cx[d$W2_cx==5] <-1
table(d$W2_cx)

table(d$W2_d)
d$W2_dx<-d$W2_d
d$W2_dx[d$W2_dx==1] <-0
d$W2_dx[d$W2_dx==2] <-1
d$W2_dx[d$W2_dx==4] <-0
table(d$W2_dx)

table(d$W2_a)
d$W2_ax<-d$W2_a
d$W2_ax[d$W2_ax==1] <-0
d$W2_ax[d$W2_ax==2] <-1
d$W2_ax[d$W2_ax==4] <-0
table(d$W2_ax)

d$index_W2quiz_manipcheck <- (d$W2_cx + d$W2_dx + d$W2_ax)/3
hist(d$index_W2quiz_manipcheck)

# 3) third set list: open ended set, word cloud

table(d$W2_mc6) # do a word clouds separately for low methods quality vs high methods quality conditions!
# GOOD RESOURCE: https://towardsdatascience.com/create-a-word-cloud-with-r-bde3e7422e8a 

#### WORD CLOUD FOR MANIPULATION CHECK
table(d$W2_mc6) # do a word clouds separately for low methods quality vs high methods quality conditions!
# GOOD RESOURCE: https://towardsdatascience.com/create-a-word-cloud-with-r-bde3e7422e8a 
library(wordcloud)
#install.packages("RColorBrewer")
library(RColorBrewer)
library(wordcloud2)
#install.packages("tm")
library(tm)
## 1) whole sample
table(d$W2_mc6)

docs <- Corpus(VectorSource(d$W2_mc6))

docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))

dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)

set.seed(1234) 

wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(8, "Dark2"))

wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=1.6, color='random-dark')


# comparing low vs high quality polls

summary(d$W2_mc6)
table(d$manips_W2_lowVshighQuality)

# low 
W2_mc6_low<-d$W2_mc6[d$manips_W2_lowVshighQuality=="Low Quality"]
W2_mc6_low<-as.vector(W2_mc6_low)
# high
W2_mc6_high<-d$W2_mc6[d$manips_W2_lowVshighQuality=="High Quality"]
W2_mc6_low<-as.vector(W2_mc6_high)

docs <- Corpus(VectorSource(W2_mc6_low))

docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))

dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)

set.seed(1234) 

wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(8, "Dark2"))

wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=1.6, color='random-dark')



# high
docs <- Corpus(VectorSource(W2_mc6_high))

docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))

dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)

set.seed(1234) 

wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(10, "Dark2"))

wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=.5, color='random-dark')



#### now re-do wordclouds by excluding W1 control!

# low 
W2_mc6_low_c1excluded<-d$W2_mc6[d$manips_W2_lowVshighQuality=="Low Quality" & d$manips_w1>1]
W2_mc6_low_c1excluded<-as.vector(W2_mc6_low_c1excluded)

# high
W2_mc6_high_c1excluded<-d$W2_mc6[d$manips_W2_lowVshighQuality=="High Quality"& d$manips_w1>1]
W2_mc6_high_c1excluded<-as.vector(W2_mc6_high_c1excluded)


# low

docs <- Corpus(VectorSource(W2_mc6_low_c1excluded))

docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))

dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)

set.seed(1234) 

wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(8, "Dark2"))

wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=1.6, color='random-dark')

#high

docs <- Corpus(VectorSource(W2_mc6_high_c1excluded))

docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))

dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)

set.seed(1234) 

wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(8, "Dark2"))

wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=1.6, color='random-dark')







#### additional: lets compare across all conditions of W2: low vs. high quality X control vs. all interventions

# 1) low quality, control
W2_mc6_lowQcontrolOnly<-d$W2_mc6[d$manips_W2_lowVshighQuality=="Low Quality" & d$manips_w1==1]
W2_mc6_lowQcontrolOnly<-as.vector(W2_mc6_lowQcontrolOnly)

# 2) high quality, control
W2_mc6_highQcontrolOnly<-d$W2_mc6[d$manips_W2_lowVshighQuality=="High Quality"& d$manips_w1==1]
W2_mc6_highQcontrolOnly<-as.vector(W2_mc6_highQcontrolOnly)

# 3) low quality, interventions
W2_mc6_lowQinterventionsOnly<-d$W2_mc6[d$manips_W2_lowVshighQuality=="Low Quality" & d$manips_w1>1]
W2_mc6_lowQinterventionsOnly<-as.vector(W2_mc6_lowQinterventionsOnly)

# 4) high quality, interventions
W2_mc6_highQinterventionsOnly<-d$W2_mc6[d$manips_W2_lowVshighQuality=="High Quality"& d$manips_w1>1]
W2_mc6_highQinterventionsOnly<-as.vector(W2_mc6_highQinterventionsOnly)


# word cloud for 1) low quality, control
W2_mc6_lowQcontrolOnly

docs <- Corpus(VectorSource(W2_mc6_lowQcontrolOnly))
docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))
dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)
set.seed(1234) 
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35)
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(5, "Dark2"))
wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=1.6, color='random-dark')

# word cloud for 2) high quality, control
W2_mc6_highQcontrolOnly

docs <- Corpus(VectorSource(W2_mc6_highQcontrolOnly))
docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))
dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)
set.seed(1234) 
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35)
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(8, "Dark2"))
wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=1.6, color='random-dark')

# word cloud for 3) low quality, interventions
W2_mc6_lowQinterventionsOnly

docs <- Corpus(VectorSource(W2_mc6_lowQinterventionsOnly))
docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))
dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)
set.seed(1234) 
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35)
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(8, "Dark2"))
wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=1.6, color='random-dark')

# word cloud for 4) high quality, interventions
W2_mc6_highQinterventionsOnly

docs <- Corpus(VectorSource(W2_mc6_highQinterventionsOnly))
docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))
dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)
set.seed(1234) 
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35)
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35,
          colors=brewer.pal(8, "Dark2"))
wordcloud2(data=df, size = 1, shape = 'pentagon')
wordcloud2(data=df, size=1.6, color='random-dark')









##### NOW LETS DO ALL EIGHT GROUPS INDEPDENDENTLY, INTERVENTIONS ONE BY ONE TOO

# 1) low quality, control
W2_mc6_lowQcontrolOnly<-d$W2_mc6[d$manips_W2_lowVshighQuality=="Low Quality" & d$manips_w1==1]
W2_mc6_lowQcontrolOnly<-as.vector(W2_mc6_lowQcontrolOnly)

# 2) high quality, control
W2_mc6_highQcontrolOnly<-d$W2_mc6[d$manips_W2_lowVshighQuality=="High Quality"& d$manips_w1==1]
W2_mc6_highQcontrolOnly<-as.vector(W2_mc6_highQcontrolOnly)

# 3) low quality, int1
W2_mc6_lowQint1<-d$W2_mc6[d$manips_W2_lowVshighQuality=="Low Quality" & d$manips_w1==2]
W2_mc6_lowQint1<-as.vector(W2_mc6_lowQint1)

# 4) high quality, int1
W2_mc6_highQint1<-d$W2_mc6[d$manips_W2_lowVshighQuality=="High Quality"& d$manips_w1==2]
W2_mc6_highQint1<-as.vector(W2_mc6_highQint1)

# 5) low quality, int2
W2_mc6_lowQint2<-d$W2_mc6[d$manips_W2_lowVshighQuality=="Low Quality" & d$manips_w1==3]
W2_mc6_lowQint2<-as.vector(W2_mc6_lowQint2)

# 6) high quality, int2
W2_mc6_highQint2<-d$W2_mc6[d$manips_W2_lowVshighQuality=="High Quality"& d$manips_w1==3]
W2_mc6_highQint2<-as.vector(W2_mc6_highQint2)

# 7) low quality, int3
W2_mc6_lowQint3<-d$W2_mc6[d$manips_W2_lowVshighQuality=="Low Quality" & d$manips_w1==4]
W2_mc6_lowQint3<-as.vector(W2_mc6_lowQint3)

# 8) high quality, int3
W2_mc6_highQint3<-d$W2_mc6[d$manips_W2_lowVshighQuality=="High Quality"& d$manips_w1==4]
W2_mc6_highQint3<-as.vector(W2_mc6_highQint3)


# produce 8 clouds by changing the variable code here, no need to post all code separately
# low quality ones, replicate this code
docs <- Corpus(VectorSource(W2_mc6_lowQint3))
docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))
dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)
set.seed(1234) 
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35, color='blue')

# high quality ones, replicate this code
docs <- Corpus(VectorSource(W2_mc6_highQint3))
docs <- docs %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))
dtm <- TermDocumentMatrix(docs) 
matrix <- as.matrix(dtm) 
words <- sort(rowSums(matrix),decreasing=TRUE) 
df <- data.frame(word = names(words),freq=words)
set.seed(1234) 
wordcloud(words = df$word, freq = df$freq, min.freq = 1,
          max.words=500, random.order=FALSE, rot.per=0.35)



##### end of word cloud code









# representativeness of poll viewed - can be considered DV too, but we asked this at very end as it
#might be too obvious signal to respondents
table(d$W2_mc3_Representative)
d$perceived_representativenss <-d$W2_mc3_Representative
d$perceived_representativenss01 <- (d$perceived_representativenss -1)/4
table(d$perceived_representativenss01)

table(d$W2_e)
d$worried_misuseOfPolls <- d$W2_e
d$worried_misuseOfPolls01 <- (d$worried_misuseOfPolls -1)/4
table(d$worried_misuseOfPolls01)

table(d$W2_Q632)
d$informative_TwitterInstaPolls <- d$W2_Q632
d$informative_TwitterInstaPolls01 <- (d$informative_TwitterInstaPolls -1)/4
table(d$informative_TwitterInstaPolls01)

# 4) fourth set list: (general poll credibility, this is not DV or relates to specific exposures)
table(d$W2_credible) # also difference from BOTH W1 pretest and W1 posttest
table(d$W2_accurate) # also difference from W1 posttest
table(d$W2_informative) # also difference from W1 posttest

d$W2_credible_W2manipcheck <- d$W2_credible
d$W2_credible_W2manipcheck01 <- (d$W2_credible_W2manipcheck-1)/4
table(d$W2_credible_W2manipcheck01)

d$W2_accurate_W2manipcheck <- d$W2_accurate
d$W2_accurate_W2manipcheck01 <- (d$W2_accurate_W2manipcheck-1)/4
table(d$W2_accurate_W2manipcheck01)

d$W2_informative_W2manipcheck <- d$W2_informative
d$W2_informative_W2manipcheck01 <- (d$W2_informative_W2manipcheck-1)/4
table(d$W2_informative_W2manipcheck01)

d$index3item_generalpollcredibility_W2_manipcheck <- (d$W2_credible_W2manipcheck01 + d$W2_accurate_W2manipcheck01 + 
                                             d$W2_informative_W2manipcheck01)/3
table(d$index3item_generalpollcredibility_W2_manipcheck)
hist(d$index3item_generalpollcredibility_W2_manipcheck)

# diff score (for first item only) from W1-PRETEST
# W2 - pre W1
d$Diff_W2minusW1pretest_credible_pollsInGeneral <-d$W2_credible_W2manipcheck01 - d$pre_credible_01 
table(d$Diff_W2minusW1pretest_credible_pollsInGeneral)
hist(d$Diff_W2minusW1pretest_credible_pollsInGeneral) # overall credibility dropped, despite 3 intervention conditions

# diff score for all 3 items that was asked W1-POST too
# W2 - post W1
d$Diff_W2minusW1posttest_credible_pollsInGeneral <-d$W2_credible_W2manipcheck01 - d$poll_credible_W1post_manipcheck01 
table(d$Diff_W2minusW1posttest_credible_pollsInGeneral)
d$Diff_W2minusW1posttest_accurate_pollsInGeneral <-d$W2_accurate_W2manipcheck01 - d$poll_accurate_W1post_manipcheck01 
table(d$Diff_W2minusW1posttest_accurate_pollsInGeneral)
d$Diff_W2minusW1posttest_informative_pollsInGeneral <-d$W2_informative_W2manipcheck01 - d$poll_informative_W1post_manipcheck01 
table(d$Diff_W2minusW1posttest_informative_pollsInGeneral)
# index for W2-W1post
d$Diff_W2minusW1posttest_3itemIndex_credibility_pollsInGeneral <-(d$Diff_W2minusW1posttest_credible_pollsInGeneral+
                                                                    d$Diff_W2minusW1posttest_accurate_pollsInGeneral+
                                                                    d$Diff_W2minusW1posttest_informative_pollsInGeneral)/3
hist(d$Diff_W2minusW1posttest_3itemIndex_credibility_pollsInGeneral)


# general concern about misuse of polls
table(d$W2_concern1)
d$W2_concern1_01 <- (d$W2_concern1-1)/4
table(d$W2_concern1_01)

table(d$W2_concern2)
d$W2_concern2_01 <- (d$W2_concern2-1)/4
table(d$W2_concern2_01)

table(d$W2_concern3)
d$W2_concern3_01 <- (d$W2_concern3-1)/4
table(d$W2_concern3_01)

# index
d$index_pollgeneralConcern3items_W2 <- (d$W2_concern1_01+d$W2_concern2_01+d$W2_concern3_01)/3
hist(d$index_pollgeneralConcern3items_W2)



#diff scores:
# diff from W1 pretest - first concern item only
d$Diff_W2minusW1pretest_concern1_pollsInGeneral <-d$W2_concern1_01 - d$pre_concern1_01 
table(d$Diff_W2minusW1pretest_concern1_pollsInGeneral)
hist(d$Diff_W2minusW1pretest_concern1_pollsInGeneral)

# W2 - post W1
d$Diff_W2minusW1posttest_concern1_pollsInGeneral <-d$W2_concern1_01 - d$poll_concern1_W1post01 
table(d$Diff_W2minusW1posttest_concern1_pollsInGeneral)
d$Diff_W2minusW1posttest_concern2_pollsInGeneral <-d$W2_concern2_01 - d$poll_concern2_W1post01 
table(d$Diff_W2minusW1posttest_concern2_pollsInGeneral)
d$Diff_W2minusW1posttest_concern3_pollsInGeneral <-d$W2_concern3_01 - d$poll_concern3_W1post01 
table(d$Diff_W2minusW1posttest_concern3_pollsInGeneral)
# index for W2-W1post
d$Diff_W2minusW1posttest_3itemIndex_concern_pollsInGeneral <-(d$Diff_W2minusW1posttest_concern1_pollsInGeneral+
                                                                    d$Diff_W2minusW1posttest_concern2_pollsInGeneral+
                                                                    d$Diff_W2minusW1posttest_concern3_pollsInGeneral)/3
hist(d$Diff_W2minusW1posttest_3itemIndex_concern_pollsInGeneral)



table(d$W2_efficacy1)
d$W2_efficacy1_polls_01 <- (d$W2_efficacy1-1)/4
table(d$W2_efficacy1_polls_01)

table(d$W2_efficacy2)
d$W2_efficacy2_polls_01 <- (d$W2_efficacy2-1)/4
table(d$W2_efficacy2_polls_01)

#index
d$index_poll_efficacy_W2 <- (d$W2_efficacy1_polls_01+d$W2_efficacy2_polls_01)/2
hist(d$index_poll_efficacy_W2)


#diff scores:
# diff from W1 pretest - first concern item only
d$Diff_W2minusW1pretest_efficacy_pollsInGeneral <-d$W2_efficacy1_polls_01 - d$pre_efficacy1_01 
table(d$Diff_W2minusW1pretest_efficacy_pollsInGeneral)
hist(d$Diff_W2minusW1pretest_efficacy_pollsInGeneral)

# W2 - post W1
d$Diff_W2minusW1posttest_efficacy1_pollsInGeneral <-d$W2_efficacy1_polls_01 - d$poll_efficacy1_W1post01 
table(d$Diff_W2minusW1posttest_efficacy1_pollsInGeneral)
d$Diff_W2minusW1posttest_efficacy2_pollsInGeneral <-d$W2_efficacy2_polls_01 - d$poll_efficacy2_W1post01 
table(d$Diff_W2minusW1posttest_efficacy2_pollsInGeneral)
# index for W2-W1post
d$Diff_W2minusW1posttest_3itemIndex_efficacy_pollsInGeneral <-(d$Diff_W2minusW1posttest_efficacy1_pollsInGeneral+
                                                                d$Diff_W2minusW1posttest_efficacy2_pollsInGeneral)/2
hist(d$Diff_W2minusW1posttest_3itemIndex_efficacy_pollsInGeneral)


### LAST MANIP CHECK ITEM
table(d$W2_mc_for_control_w2) # even this has W1 difference score! nice
d$informed_baseball_W2_manipcheck01<-d$W2_mc_for_control_w2
d$informed_baseball_W2_manipcheck01<-(d$informed_baseball_W2_manipcheck01-1)/4
table(d$informed_baseball_W2_manipcheck01)
# diff
table(d$informed_baseball_W1_manipcheck01) #w1 version
d$DIFFw2w1_baseball_informed <- d$informed_baseball_W2_manipcheck01 - d$informed_baseball_W1_manipcheck01
table(d$DIFFw2w1_baseball_informed)
hist(d$DIFFw2w1_baseball_informed)

table(d$manips_w1, d$DIFFw2w1_baseball_informed) # control condition worked











##############################################################################################################################

##############################################################################################################################

########################################## ALL MANIPULATION CHECK ANALYSES

##########################################



#################################################################################### WAVE 1

table(d$misinfo_polls_familiarity_W1_manipcheck01) # worried about misuse of polls INOCULATION
table(d$twitter_polls_familiarity_W1_manipcheck01) # twitter polls familiar INOCULATION
table(d$informed_baseball_W1_manipcheck01) # baseball CONTROL
table(d$DIFF_W1post_W1pre_pollcredible) # polls credibility in general item 1 = diff score with pre-test
table(d$index_pollcredibility_3items_W1posttest) # poll credibility 3 item index
table(d$poll_concern1_W1post01) # polls misinfo-manipulation concern item 1 
table(d$DIFF_W1post_W1pre_pollconcern) # diff score from pre-test (polls misinfo-manipulation concern)
table(d$index_pollconcern3items_W1_posttest) #indext of 3 poll concern posttest items in W1:
table(d$poll_efficacy1_W1post01) # efficacy about polls item 1 
table(d$DIFF_W1post_W1pre_pollefficacy1) # efficacy about polls item 1 - diff score
table(d$index_pollefficacy2items_W1_posttest) #index of 2 poll efficacy W1 posttest items:

# checking W1 manips at W1
st(d, vars = c('misinfo_polls_familiarity_W1_manipcheck01',
               'twitter_polls_familiarity_W1_manipcheck01',
               'informed_baseball_W1_manipcheck01',
               'DIFF_W1post_W1pre_pollcredible',
               'index_pollcredibility_3items_W1posttest',
               'poll_concern1_W1post01',
               'DIFF_W1post_W1pre_pollconcern',
               'index_pollconcern3items_W1_posttest',
               'poll_efficacy1_W1post01',
               'DIFF_W1post_W1pre_pollefficacy1',
               'index_pollefficacy2items_W1_posttest'), 
   group = 'manips_w1ff', 
   group.test = TRUE, 
   file='checks of W1 manips at W1')


####################################################################################
# W2 MANIP CHECK variables

# wordclouds 
# -> above

# first set list - descriptives
table(d$W2_mc1)
table(d$W2_mc2a1)
table(d$W2_mc2b1)
table(d$W2_mc2xa1)
table(d$W2_mc2xa2)
table(d$W2_mc2xb1)
table(d$W2_mc2xb2)
table(d$W2_mc2a2)
table(d$W2_mc2b2)
table(d$perceived_representativenss01)
table(d$W2_soup)


# checking W2 manips at W2
table(d$manips_W2_covidVsAI,d$W2_mc1)
table(d$manips_W2_covid_ConcernVsConfident,d$W2_mc2xa1)
table(d$manips_W2_covid_ConcernVsConfident,d$W2_mc2a2)
table(d$manips_W2_AIregulation_SupportVsOppose,d$W2_mc2b2)
table(d[d$manips_w1==1,]$manips_W2_lowVshighQuality,d[d$manips_w1==1,]$perceived_representativenss01)
table(d[d$manips_w1>1,]$manips_W2_lowVshighQuality,d[d$manips_w1>1,]$perceived_representativenss01)

table(d[d$manips_w1==1,]$W2_soup)
table(d[d$manips_w1>1,]$W2_soup)

r1 = aov(W2_soup~manips_w1ff, data=d) 
summary(r1)
TukeyHSD(r1)


# all other
table(d$index_W2quiz_manipcheck)
table(d$worried_misuseOfPolls01)
table(d$informative_TwitterInstaPolls01)
table(d$index3item_generalpollcredibility_W2_manipcheck)
table(d$Diff_W2minusW1pretest_credible_pollsInGeneral)
table(d$Diff_W2minusW1posttest_3itemIndex_credibility_pollsInGeneral)
table(d$index_pollgeneralConcern3items_W2)
table(d$Diff_W2minusW1pretest_concern1_pollsInGeneral)
table(d$Diff_W2minusW1posttest_3itemIndex_concern_pollsInGeneral)
table(d$index_poll_efficacy_W2)
table(d$Diff_W2minusW1pretest_efficacy_pollsInGeneral)
table(d$Diff_W2minusW1posttest_3itemIndex_efficacy_pollsInGeneral)
table(d$informed_baseball_W2_manipcheck01)
table(d$DIFFw2w1_baseball_informed)


# checking W1 manips at W2 (but be careful, these scores may also impacted by W2 manip exposure...so)
st(d, vars = c('index_W2quiz_manipcheck',
               'worried_misuseOfPolls01',
               'informative_TwitterInstaPolls01',
               'index3item_generalpollcredibility_W2_manipcheck',
               'Diff_W2minusW1pretest_credible_pollsInGeneral',
               'Diff_W2minusW1posttest_3itemIndex_credibility_pollsInGeneral',
               'index_pollgeneralConcern3items_W2',
               'Diff_W2minusW1pretest_concern1_pollsInGeneral',
               'Diff_W2minusW1posttest_3itemIndex_concern_pollsInGeneral',
               'index_poll_efficacy_W2',
               'Diff_W2minusW1pretest_efficacy_pollsInGeneral',
               'Diff_W2minusW1posttest_3itemIndex_efficacy_pollsInGeneral',
               'informed_baseball_W2_manipcheck01',
               'DIFFw2w1_baseball_informed'), 
   group = 'manips_w1ff', 
   group.test = TRUE, 
   file='checks of W1 manips at W2')






###################### ############### ############### ###############  LIST OF ALL VARIABLES ############### ############### 

############### # W1 
d$manips_w1
d$manips_w2

d$days
d$Age_Years
d$Sex_
d$Chinese01
d$Malay
d$Indian
d$OtherRace
d$liberalimputed01
d$Income01
d$educat01

# poll pretests
d$pretest_INDEX_pollInterest_W1
d$pre_credible_01 
d$pre_concern1_01
d$pre_efficacy1_01

# vax pretests
d$pretest_INDEX_vax_risk1_W1 
d$pretest_INDEX_vaxPO_risk1_W1 
d$pre_VaxPerceptPOpercent_01     
d$pre_VaxIntention_01
d$pre_Vax_Positivity_01 

# ai pretests
d$pretest_INDEX_AI_risk1_W1
d$pretest_INDEX_aiPO_risk1_W1
d$pre_aiPerceptPOpercent_01 
d$pre_AI_PolicyView_01 
d$pre_ai_Positivity_01

# pretest moderators
d$index_NewsLitBehave_W1
d$subjnum_W1
d$esl_total01

# experiment in-built items
d$control_W1_inbuilt_IntentionBaseball # C1
d$control_W1_inbuilt_EntertainingBaseball #C1
d$c3_inbuilt_totalscore #c3
d$c4_inbuilt_totalscore #c4
# note: C2 is passive literacy, it has not inbuilt questions (quiz)

# control vars
d$numberofC19vax
d$sideEffectSeverity
d$experienceAI_01

#### W1 manip checks list ready to analyze
d$misinfo_polls_familiarity_W1_manipcheck01 # worried about misuse of polls INOCULATION
d$twitter_polls_familiarity_W1_manipcheck01 # twitter polls familiar INOCULATION
d$informed_baseball_W1_manipcheck01 # baseball CONTROL
d$poll_credible_W1post_manipcheck01 # polls credibility in general item 1 
d$DIFF_W1post_W1pre_pollcredible # polls credibility in general item 1 W1 post-W1 pretest diff
d$poll_accurate_W1post_manipcheck01 #  polls credibility in general item 2
d$poll_informative_W1post_manipcheck01 # polls credibility in general item 2
d$index_pollcredibility_3items_W1posttest # index of credible, accurate, informative
d$poll_concern1_W1post01 # polls misinfo-manipulation concern item 1
d$DIFF_W1post_W1pre_pollconcern # polls misinfo-manipulation concern item 1 W1 posttest - W1 pretest
d$poll_concern2_W1post01 # polls misinfo-manipulation concern item 1
d$poll_concern3_W1post01 # polls misinfo-manipulation concern item 2
d$index_pollconcern3items_W1_posttest # polls misinfo-manipulation concern item 1-2-3 index
d$poll_efficacy1_W1post01 # efficacy about polls item 1
d$DIFF_W1post_W1pre_pollefficacy1 # efficacy about polls item 1 W1 post - W1 pre diff
d$poll_efficacy2_W1post01 # efficacy about polls item 2
d$index_pollefficacy2items_W1_posttest # efficacy about polls index of 2 items 




############### List of W2 Variables 

d$pretest_INDEX_pollInterest_W2
d$pretest_INDEX_pollInterest_w2minusw1
d$index_trustinscinece_A_W2
d$index_trustinscinece_B_W2

# poll cred DV - only crossectional
d$pollcred_DV_4 # includes 4 items
d$pollcred_DV_5 # 4 itesms + representativeness item

# vax and ai dv
#crossect
d$W2_posttest_INDEX_vax_risk1_W2
d$W2_posttest_INDEX_vaxPO_risk1_W2
d$W2_post_VaxPerceptPOpercent_01
d$W2_post_VaxIntention_01
d$W2_post_Vax_Positivity_01

d$W2_posttest_INDEX_AI_risk1_W2
d$W2_posttest_INDEX_aiPO_risk1_W2
d$W2_post_aiPerceptPOpercent_01
d$W2_post_AI_PolicyView_01
d$W2_post_ai_Positivity_01

#diff scores

d$DIFFw2w1_INDEX_vax_risk1
d$DIFFw2w1_INDEX_vaxPO_risk1
d$DIFFw2w1_VaxPerceptPOpercent
d$DIFFw2w1_VaxIntention
d$DIFFw2w1_Vax_Positivity
d$DIFFw2w1_INDEX_AI_risk1
d$DIFFw2w1_INDEX_aiPO_risk1
d$DIFFw2w1_aiPerceptPOpercent_01
d$DIFFw2w1_AI_PolicyView_01
d$DIFFw2w1_ai_Positivity_01

# media
d$W2_index_TradNews_W1
d$W2_index_SocialNews_W1
d$W2_index_MessAppNews_W1

# interference
d$interfere_poll
d$interfere_vax
d$interfere_ai

#all manips W1 and W2
#w1
d$manips_w1
d$manips_w1ff
d$manips_w1_C1vsC234
d$manips_w1_C1vsC23vsC4
d$manips_w1_C1vsC2vsC34
#w2
d$manips_w2ff
d$manips_W2_lowVshighQuality
d$manips_W2_covidVsAI
d$manips_W2_covid_ConcernVsConfident
d$manips_W2_AIregulation_SupportVsOppose

#disagreement\unfavorable\unexpected factors
d$RseenAttitudeInconsistentPO_vaxrisk_absolute # using vax risk perception pretest item (respondent pretest)
d$RseenAttitudeInconsistentPO_AIrisk_absolute # using ai risk perception pretest item (respondent pretest)
d$RseenAttitudeInconsistentPO_vaxIntention_absolute # using vax intention (respondent pretest) # ALTERNATIVE
d$RseenAttitudeInconsistentPO_aiPolicy_absolute # using support for ai regulation (respondent pretest) # ALTERNATIVE
d$RseenPOperceptionInconsistentPO_vaxrisk_absolute # using vax PO perception verbal item (respondent pretest) # ALTERNATIVE
d$RseenPOperceptionInconsistentPO_AIrisk_absolute # using AI PO perception verbal item (respondent pretest) # ALTERNATIVE
d$RseenPOPercentperceptionInconsistentPO_Vaxrisk_absolute # using vax PO perception % item (respondent pretest) NOTE: .50 expecters are NA from this # ALTERNATIVE
d$RseenPOPercentperceptionInconsistentPO_AIrisk_absolute # using AI PO perception % item (respondent pretest) NOTE: .50 expecters are NA from this # ALTERNATIVE

# list of W2 manip checks
table(d$W2_mc1)
table(d$W2_mc2a1)
table(d$W2_mc2b1)
table(d$W2_mc2xa1)
table(d$W2_mc2xa2)
table(d$W2_mc2xb1)
table(d$W2_mc2xb2)
table(d$W2_mc2a2)
table(d$W2_mc2b2)
d$index_W2quiz_manipcheck 
d$W2_mc6 # open-ended for wordcloud
d$perceived_representativenss01
d$worried_misuseOfPolls01
d$informative_TwitterInstaPolls01
d$W2_credible_W2manipcheck01
d$W2_accurate_W2manipcheck01
d$W2_informative_W2manipcheck01
d$index3item_generalpollcredibility_W2_manipcheck 
d$Diff_W2minusW1pretest_credible_pollsInGeneral
d$Diff_W2minusW1posttest_credible_pollsInGeneral
d$Diff_W2minusW1posttest_accurate_pollsInGeneral
d$Diff_W2minusW1posttest_informative_pollsInGeneral
d$Diff_W2minusW1posttest_3itemIndex_credibility_pollsInGeneral
d$index_pollgeneralConcern3items_W2
d$Diff_W2minusW1pretest_concern1_pollsInGeneral
d$Diff_W2minusW1posttest_concern1_pollsInGeneral
d$Diff_W2minusW1posttest_concern2_pollsInGeneral
d$Diff_W2minusW1posttest_concern3_pollsInGeneral
d$Diff_W2minusW1posttest_3itemIndex_concern_pollsInGeneral
d$W2_efficacy1_polls_01
d$W2_efficacy2_polls_01
d$index_poll_efficacy_W2
d$Diff_W2minusW1pretest_efficacy_pollsInGeneral
d$Diff_W2minusW1posttest_efficacy1_pollsInGeneral
d$Diff_W2minusW1posttest_efficacy2_pollsInGeneral
d$Diff_W2minusW1posttest_3itemIndex_efficacy_pollsInGeneral
d$informed_baseball_W2_manipcheck01
d$DIFFw2w1_baseball_informed













### ALL ANALYSES:

### manipulation check analysis

#### W1 manip checks list ready to analyze
d$misinfo_polls_familiarity_W1_manipcheck01 # worried about misuse of polls INOCULATION
d$twitter_polls_familiarity_W1_manipcheck01 # twitter polls familiar INOCULATION
d$informed_baseball_W1_manipcheck01 # baseball CONTROL
d$poll_credible_W1post_manipcheck01 # polls credibility in general item 1 
d$DIFF_W1post_W1pre_pollcredible # polls credibility in general item 1 W1 post-W1 pretest diff
d$poll_accurate_W1post_manipcheck01 #  polls credibility in general item 2
d$poll_informative_W1post_manipcheck01 # polls credibility in general item 2
d$index_pollcredibility_3items_W1posttest # index of credible, accurate, informative
d$poll_concern1_W1post01 # polls misinfo-manipulation concern item 1
d$DIFF_W1post_W1pre_pollconcern # polls misinfo-manipulation concern item 1 W1 posttest - W1 pretest
d$poll_concern2_W1post01 # polls misinfo-manipulation concern item 1
d$poll_concern3_W1post01 # polls misinfo-manipulation concern item 2
d$index_pollconcern3items_W1_posttest # polls misinfo-manipulation concern item 1-2-3 index
d$poll_efficacy1_W1post01 # efficacy about polls item 1
d$DIFF_W1post_W1pre_pollefficacy1 # efficacy about polls item 1 W1 post - W1 pre diff
d$poll_efficacy2_W1post01 # efficacy about polls item 2
d$index_pollefficacy2items_W1_posttest # efficacy about polls index of 2 items 

# list of W2 manip checks
table(d$W2_mc1)
table(d$W2_mc2a1)
table(d$W2_mc2b1)
table(d$W2_mc2xa1)
table(d$W2_mc2xa2)
table(d$W2_mc2xb1)
table(d$W2_mc2xb2)
table(d$W2_mc2a2)
table(d$W2_mc2b2)
d$index_W2quiz_manipcheck
d$W2_mc6 # open-ended for wordcloud
d$perceived_representativenss01
d$worried_misuseOfPolls01
d$informative_TwitterInstaPolls01
d$W2_credible_W2manipcheck01
d$W2_accurate_W2manipcheck01
d$W2_informative_W2manipcheck01
d$index3item_generalpollcredibility_W2_manipcheck 
d$Diff_W2minusW1pretest_credible_pollsInGeneral
d$Diff_W2minusW1posttest_credible_pollsInGeneral
d$Diff_W2minusW1posttest_accurate_pollsInGeneral
d$Diff_W2minusW1posttest_informative_pollsInGeneral
d$Diff_W2minusW1posttest_3itemIndex_credibility_pollsInGeneral
d$index_pollgeneralConcern3items_W2
d$Diff_W2minusW1pretest_concern1_pollsInGeneral
d$Diff_W2minusW1posttest_concern1_pollsInGeneral
d$Diff_W2minusW1posttest_concern2_pollsInGeneral
d$Diff_W2minusW1posttest_concern3_pollsInGeneral
d$Diff_W2minusW1posttest_3itemIndex_concern_pollsInGeneral
d$W2_efficacy1_polls_01
d$W2_efficacy2_polls_01
d$index_poll_efficacy_W2
d$Diff_W2minusW1pretest_efficacy_pollsInGeneral
d$Diff_W2minusW1posttest_efficacy1_pollsInGeneral
d$Diff_W2minusW1posttest_efficacy2_pollsInGeneral
d$Diff_W2minusW1posttest_3itemIndex_efficacy_pollsInGeneral
d$informed_baseball_W2_manipcheck01
d$DIFFw2w1_baseball_informed













# equivalence of conditions - only for W1

#results summary
# note that in output table: Statistical significance markers: * p<0.1; ** p<0.05; *** p<0.01

#install.packages("vtable")
library(vtable)
st(d, vars = c('Age_Years',
               'Sex_',
               'Chinese01',
               'Malay',
               'Indian',
               'OtherRace',
               'liberalimputed01',
               'Income01',
               'educat01',
               'pretest_INDEX_pollInterest_W1',
               'pre_credible_01', 
               'pre_concern1_01',
               'pre_efficacy1_01',
               'pretest_INDEX_vax_risk1_W1', 
               'pretest_INDEX_vaxPO_risk1_W1', 
               'pre_VaxPerceptPOpercent_01',     
               'pre_VaxIntention_01',
               'pre_Vax_Positivity_01', 
               'pretest_INDEX_AI_risk1_W1',
               'pretest_INDEX_aiPO_risk1_W1',
               'pre_aiPerceptPOpercent_01',
               'pre_AI_PolicyView_01',
               'pre_ai_Positivity_01',
               'index_NewsLitBehave_W1',
               'subjnum_W1',
               'esl_total01'), 
   group = 'manips_w1', 
   group.test = TRUE, 
   file='equivalence_of_conditions by W1')

st(d, vars = c('Age_Years',
               'Sex_',
               'Chinese01',
               'Malay',
               'Indian',
               'OtherRace',
               'liberalimputed01',
               'Income01',
               'educat01',
               'pretest_INDEX_pollInterest_W1',
               'pre_credible_01', 
               'pre_concern1_01',
               'pre_efficacy1_01',
               'pretest_INDEX_vax_risk1_W1', 
               'pretest_INDEX_vaxPO_risk1_W1', 
               'pre_VaxPerceptPOpercent_01',     
               'pre_VaxIntention_01',
               'pre_Vax_Positivity_01', 
               'pretest_INDEX_AI_risk1_W1',
               'pretest_INDEX_aiPO_risk1_W1',
               'pre_aiPerceptPOpercent_01',
               'pre_AI_PolicyView_01',
               'pre_ai_Positivity_01',
               'index_NewsLitBehave_W1',
               'subjnum_W1',
               'esl_total01'), 
   group = 'manips_w2', 
   group.test = TRUE, 
   file='equivalence_of_conditions by W2')

names(d)
### cell balance
table(d$manips_w1)
table(d$manips_w2)
table(d$manips_w1, d$manips_w2) # including to show no differential attrition - insignficant, no hetereogeneity
chisq.test(d$manips_w1, d$manips_w2)
table(d$manips_w1, d$manips_w2ff) # showing just W2s without dropouts - insignficant, no hetereogeneity
chisq.test(d$manips_w1, d$manips_w2ff)




# testing all 32 conditions at once

table(d$manips_w1)
d$manips_w1XX<-d$manips_w1
table(d$manips_w1XX)
d$manips_w1XX[d$manips_w1XX==1] <- 1
d$manips_w1XX[d$manips_w1XX==2] <- 9
d$manips_w1XX[d$manips_w1XX==3] <- 17
d$manips_w1XX[d$manips_w1XX==4] <- 25
table(d$manips_w1XX)
  
table(d$manips_w2ff)
d$manips_w2ffXX<-as.numeric(d$manips_w2ff)
table(d$manips_w2ffXX)

d$manips32<-d$manips_w1XX*d$manips_w2ffXX
table(d$manips32)

st(d, vars = c('Age_Years',
               'Sex_',
               'Chinese01',
               'Malay',
               'Indian',
               'OtherRace',
               'liberalimputed01',
               'Income01',
               'educat01',
               'pretest_INDEX_pollInterest_W1',
               'pre_credible_01', 
               'pre_concern1_01',
               'pre_efficacy1_01',
               'pretest_INDEX_vax_risk1_W1', 
               'pretest_INDEX_vaxPO_risk1_W1', 
               'pre_VaxPerceptPOpercent_01',     
               'pre_VaxIntention_01',
               'pre_Vax_Positivity_01', 
               'pretest_INDEX_AI_risk1_W1',
               'pretest_INDEX_aiPO_risk1_W1',
               'pre_aiPerceptPOpercent_01',
               'pre_AI_PolicyView_01',
               'pre_ai_Positivity_01',
               'index_NewsLitBehave_W1',
               'subjnum_W1',
               'esl_total01',
               'sideEffectSeverity',
              'experienceAI_01'), 
   group = 'manips32', 
   group.test = TRUE, 
   file='equivalence_of_conditions by W2')







## descriptives table

d$Sex_fac<-as.factor(d$Sex_)
d$Chinese01_fac<-as.factor(d$Chinese01)
d$Malay_fac<-as.factor(d$Malay)
d$Indian_fac<-as.factor(d$Indian)
d$OtherRace_fac<-as.factor(d$OtherRace)

# W1
st(d, vars = c('Age_Years',
               'Sex_fac',
               'Chinese01_fac',
               'Malay_fac',
               'Indian_fac',
               'OtherRace_fac',
               'liberalimputed01',
               'Income01',
               'educat01',
               'pretest_INDEX_pollInterest_W1',
               'pre_credible_01', 
               'pre_concern1_01',
               'pre_efficacy1_01',
               'pretest_INDEX_vax_risk1_W1', 
               'pretest_INDEX_vaxPO_risk1_W1', 
               'pre_VaxPerceptPOpercent_01',     
               'pre_VaxIntention_01',
               'pre_Vax_Positivity_01', 
               'pretest_INDEX_AI_risk1_W1',
               'pretest_INDEX_aiPO_risk1_W1',
               'pre_aiPerceptPOpercent_01',
               'pre_AI_PolicyView_01',
               'pre_ai_Positivity_01',
               'index_NewsLitBehave_W1',
               'subjnum_W1',
               'esl_total01',
               'sideEffectSeverity',
               'experienceAI_01'),   
   add.median = TRUE, 
   factor.percent = TRUE, 
   factor.counts = TRUE,
   file='descriptives_W1')


#W2
st(d[d$BothWaversDummy==2,], vars = c('Age_Years',
               'Sex_fac',
               'Chinese01_fac',
               'Malay_fac',
               'Indian_fac',
               'OtherRace_fac',
               'liberalimputed01',
               'Income01',
               'educat01',
               'pretest_INDEX_pollInterest_W1',
               'pre_credible_01', 
               'pre_concern1_01',
               'pre_efficacy1_01',
               'pretest_INDEX_vax_risk1_W1', 
               'pretest_INDEX_vaxPO_risk1_W1', 
               'pre_VaxPerceptPOpercent_01',     
               'pre_VaxIntention_01',
               'pre_Vax_Positivity_01', 
               'pretest_INDEX_AI_risk1_W1',
               'pretest_INDEX_aiPO_risk1_W1',
               'pre_aiPerceptPOpercent_01',
               'pre_AI_PolicyView_01',
               'pre_ai_Positivity_01',
               'index_NewsLitBehave_W1',
               'subjnum_W1',
               'esl_total01',
               'sideEffectSeverity',
               'experienceAI_01'),  
   add.median = TRUE, 
   factor.percent = TRUE, 
   factor.counts = TRUE,
   file='descriptives_W2')



# dropouts 
st(d[d$BothWaversDummy==1,], vars = c('Age_Years',
                                      'Sex_fac',
                                      'Chinese01_fac',
                                      'Malay_fac',
                                      'Indian_fac',
                                      'OtherRace_fac',
                                      'liberalimputed01',
                                      'Income01',
                                      'educat01',
                                      'pretest_INDEX_pollInterest_W1',
                                      'pre_credible_01', 
                                      'pre_concern1_01',
                                      'pre_efficacy1_01',
                                      'pretest_INDEX_vax_risk1_W1', 
                                      'pretest_INDEX_vaxPO_risk1_W1', 
                                      'pre_VaxPerceptPOpercent_01',     
                                      'pre_VaxIntention_01',
                                      'pre_Vax_Positivity_01', 
                                      'pretest_INDEX_AI_risk1_W1',
                                      'pretest_INDEX_aiPO_risk1_W1',
                                      'pre_aiPerceptPOpercent_01',
                                      'pre_AI_PolicyView_01',
                                      'pre_ai_Positivity_01',
                                      'index_NewsLitBehave_W1',
                                      'subjnum_W1',
                                      'esl_total01',
                                      'sideEffectSeverity',
                                      'experienceAI_01'),  
   add.median = TRUE, 
   factor.percent = TRUE, 
   factor.counts = TRUE,
   file='descriptives_dropouts')











### further appendix tests

## controls media, demog, theoretical, interference, days gap (outlier analysis for few cases too- by removing them..)

## attrition analysis - # but also test differential attrition 4 W1 conditions - there is none, but test a chisquare.

library(vtable)

st(d, vars = c('Age_Years',
               'Sex_',
               'Chinese01',
               'Malay',
               'Indian',
               'OtherRace',
               'liberalimputed01',
               'Income01',
               'educat01',
               'pretest_INDEX_pollInterest_W1',
               'pre_credible_01', 
               'pre_concern1_01',
               'pre_efficacy1_01',
               'pretest_INDEX_vax_risk1_W1', 
               'pretest_INDEX_vaxPO_risk1_W1', 
               'pre_VaxPerceptPOpercent_01',     
               'pre_VaxIntention_01',
               'pre_Vax_Positivity_01', 
               'pretest_INDEX_AI_risk1_W1',
               'pretest_INDEX_aiPO_risk1_W1',
               'pre_aiPerceptPOpercent_01',
               'pre_AI_PolicyView_01',
               'pre_ai_Positivity_01',
               'index_NewsLitBehave_W1',
               'subjnum_W1',
               'esl_total01'), 
   group = 'sample_indicator', 
   group.test = TRUE, 
   file='attrition_comparison')




# descriptives
#install.packages("pastecs")
library(pastecs)
# main outcome credibility
stat.desc(d$pollcred_DV_5)
stat.desc(d$pollcred_DV_4)
# public opinion perceptions

# verbal perceptions 
## vaccine
### diff score vaccine
stat.desc(d$DIFFw2w1_INDEX_vaxPO_risk1)
### crosssectional vaccine
stat.desc(d$W2_posttest_INDEX_vaxPO_risk1_W2)
## AI
### diff score AI
stat.desc(d$DIFFw2w1_INDEX_aiPO_risk1)
### crosssectional AI
stat.desc(d$W2_posttest_INDEX_aiPO_risk1_W2)

# percentage perceptions
## vaccine
### diff score vaccine
stat.desc(d$DIFFw2w1_VaxPerceptPOpercent)
### crossectional vaccine
stat.desc(d$W2_post_VaxPerceptPOpercent_01)
## AI
### diff score AI
stat.desc(d$DIFFw2w1_aiPerceptPOpercent_01)
### crossectional AI
stat.desc(d$W2_post_aiPerceptPOpercent_01)


# unfavorable 
## vax
stat.desc(d$RseenAttitudeInconsistentPO_vaxrisk_absolute)
## AI
stat.desc(d$RseenAttitudeInconsistentPO_AIrisk_absolute)

# moderators
stat.desc(d$educat01)
describe(d$educat01)
describe(as.numeric(d$EducationSG))
stat.desc(d$esl_total01)
stat.desc(d$subjnum_W1)
stat.desc(d$index_NewsLitBehave_W1)
stat.desc(d$pretest_INDEX_pollInterest_W1)




# MAIN ANALYSES: Hs and RQs




#1_ Manuscript MODELS: balance test required controls 
Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI

#2 NO control list MODELS

#3 FULL control list MODELS
Age_Years + Sex_ + Chinese01 + Malay + Indian + OtherRace +
  liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
  pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
  subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
  W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
  sideEffectSeverity + experienceAI_01 +
  interfere_poll + interfere_vax + interfere_ai







################################ ################ ################ ################  
#### 1_ Manuscript MODELS: balance test required controls 
################################ ################ ################ ################  





################################ ################ ################ ################  1) CREDIBILITY

d$pollcred_DV_4 # this is provided in appendix 
d$pollcred_DV_5 

#  I have to look at it only among W1 control too (H1), because most are from interventions:
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality+ Chinese01 + Indian + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI, data=d[d$manips_w1==1,])
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality+ Chinese01 + Indian + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI, data=d[d$manips_w1==1,])
summary(r1)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality+ Chinese01 + Indian + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI, data=d[d$manips_w1>1,])
summary(r1)
stargazer(r1, type = "text", out = "only_among_interventions.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 

# method quality matter OVERALL but this is driven by interventions, as above we show that among control there is no such effect!
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality+Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI, data=d)
summary(r1)
TukeyHSD(r1)
# method quality mattering interact with trainings!
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
         +d$Age_Years + d$Chinese01 + 
           d$Indian + d$pretest_INDEX_pollInterest_W1 + d$manips_W2_covidVsAI, 
         data=d) 
# one alternative is to have covariates turn to factors, but this changes p values slightly, not proper way to test the pairwise differences
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
         +as.factor(d$Age_Years) + as.factor(d$Chinese01) + 
           as.factor(d$Indian) + as.factor(d$pretest_INDEX_pollInterest_W1) + as.factor(d$manips_W2_covidVsAI), 
         data=d) 
summary(r1)
TukeyHSD(r1)
TukeyHSD(r1, "manips_W2_lowVshighQuality")
TukeyHSD(r1, "manips_w1ff")
TukeyHSD(r1, "manips_W2_lowVshighQuality:manips_w1ff")


r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
Anova(r1)

r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
         +as.factor(d$Age_Years) + as.factor(d$Chinese01) + 
           as.factor(d$Indian) + as.factor(d$pretest_INDEX_pollInterest_W1) + as.factor(d$manips_W2_covidVsAI), 
         data=d) 
summary(r1)
TukeyHSD(r1)

x1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
         +d$Age_Years + d$Chinese01 + 
           d$Indian + d$pretest_INDEX_pollInterest_W1 + d$manips_W2_covidVsAI, 
         data=d) 
summary(x1)
plot(x1, which = 2)
qqPlot(x1$residuals,
       id = FALSE 
)
TukeyHSD(x1, 'manips_W2_lowVshighQuality')
TukeyHSD(x1, "manips_w1ff")
TukeyHSD(x1, "manips_W2_lowVshighQuality:manips_w1ff")

par(mar = c(4.1, 31.5, 4.1, 1.1)) # set axis margins to prevent labels off screen
plot(TukeyHSD(x1, which = "manips_W2_lowVshighQuality:manips_w1ff"),
     las = 2 # rotate x-axis ticks
)


res_tukey <- glht(
  aov(pollcred_DV_5 ~ manips_W2_lowVshighQuality + manips_w1ff,
      data = d
  ),
  linfct = mcp(manips_W2_lowVshighQuality = "Tukey")
)
summary(res_tukey)

res_tukey <- glht(
  aov(pollcred_DV_5 ~ manips_W2_lowVshighQuality + manips_w1ff, #https://statsandr.com/blog/two-way-anova-in-r/ (keep + and do not enter as * interaction for this test)
      data = d
  ),
  linfct = mcp(manips_w1ff = "Tukey")
)
summary(res_tukey)

#Anova(r1, type = "III")
etaSquared(r1, type = 2, anova = TRUE )
#plot(r1)
TukeyHSD(r1, "manips_W2_lowVshighQuality")
TukeyHSD(r1, "manips_w1ff")

#install.packages("lsr")
library(lsr)
#install.packages("rstatix")
library(rstatix)
#install.packages("emmeans")
library(emmeans)
#install.packages("tidyverse")
library(tidyverse)
library(ggpubr)
library(rstatix)
library(broom)
# have to turn factor covariates to numerics
#Chinese01 + Indian + manips_W2_covidVsAI

d$Chinese01_num <- as.numeric(d$Chinese01)
d$Indian_num <- as.numeric(d$Indian)
d$manips_W2_covidVsAI_num <- as.numeric(d$manips_W2_covidVsAI)


pwc<- d %>% 
  group_by(manips_W2_lowVshighQuality) %>%
  emmeans_test(
    pollcred_DV_5 ~ manips_w1ff, 
    covariate = c(Age_Years, d$Chinese01_num, d$Indian_num, pretest_INDEX_pollInterest_W1),
    p.adjust.method = "bonferroni", detailed=TRUE)
get_emmeans(pwc)

pwc %>% filter(manips_W2_lowVshighQuality == "High Quality")
pwc %>% filter(manips_W2_lowVshighQuality == "Low Quality")



#install.packages("multcomp")
library(multcomp)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
# difference between active lit and inoculation JUST MAIN EFFECTS (4th and 5th terms, respectively)
r1$coef[4]
r1$coef[5]
r1$coef[4] - r1$coef[5]
# and this contrast coding approach gives us significance test too:
K <- matrix(c(0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0), 1)
t <- glht(r1, linfct = K)
summary(t) # NOTE THAT THIS IGNORES INTERACTION PARTS...SEE BELOW FOR FULL PROPER COMPARISON OF ALL EFFECTS:



# *******************FEBRUARY 2025 EDIT START HERE
# well, i can do this to test the INTERACTION coefficients too, to test intervention differences! 

# inoc vs. active: inoculation is SIGNIFICANTLY better in inducing low vs high quality differentiation than active literacy
# for example comparing coef 13 (inoculation) against coef 12 (active lit)
# difference between active lit and inoculation (12th and 13th terms, respectively)
r1$coef[13]
r1$coef[12]
r1$coef[13] - r1$coef[12]
# and this contrast coding approach gives us significance test too:
K <- matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1), 1)
K
t <- glht(r1, linfct = K)
summary(t)

# inoc vs. passive: inoculation is SIGNIFICANTLY better in inducing low vs high quality differentiation than passive literacy
# for example comparing coef 13 (inoculation) against coef 12 (active lit)
# difference between active lit and inoculation (12th and 13th terms, respectively)
r1$coef[13]
r1$coef[11]
r1$coef[13] - r1$coef[11]
# and this contrast coding approach gives us significance test too:
K <- matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1), 1)
t <- glht(r1, linfct = K)
summary(t)

# passive vs. active: NOT SIGNIFICANT
# for example comparing coef 13 (inoculation) against coef 12 (active lit)
# difference between active lit and inoculation (12th and 13th terms, respectively)
r1$coef[12]
r1$coef[11]
r1$coef[12] - r1$coef[11]
# and this contrast coding approach gives us significance test too:
K <- matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0), 1)
t <- glht(r1, linfct = K)
summary(t)

# INOC vs. CONTROL: (this is only trial)
r1$coef[13]
r1$coef[2]
r1$coef[13] - r1$coef[2]
# and this contrast coding approach gives us significance test too:
K <- matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0), 1)
K
t <- glht(r1, linfct = K)
summary(t)

# alternative coding, multi-step, creat 2 vectors and take difference and see if same result to ensure what i did in comparing interaction coefs above is correct:
# https://stats.oarc.ucla.edu/r/faq/how-can-i-test-contrasts-in-r/

#CONTROL VS PASSIVE – none as I know from original interaction coefficient in regression
#CONTROL VS ACTIVE – none as I know from original interaction coefficient in regression
#CONTROL VS INOC – SIGNIFICANT as I know from original interaction coefficient in regression
#PASSIVE VS ACTIVE- NONE
#PASSIVE VS INOC - SIGNIFICANT
#ACTIVE VS INOC – SIGNIFICANT

# or consider parametric bootstrapping: search "use parametric bootstrapping for testing interaction coefficient differences in regression"
# https://olebo.github.io/textbook/ch/18/hyp_regression.html


# # *******************FEBRUARY 2025 EDIT END HERE








# but coding contrasts is complicated, as seen in examples here:https://stats.oarc.ucla.edu/r/faq/how-can-i-test-contrasts-in-r/
# instead we can do all pairwise constrasts at once using OLS model too, like automatically done in Tukey
# all pairwise comparsions
# creating a BIG group variable
d$interactioncontrasts <- with(d, interaction(manips_W2_lowVshighQuality, manips_w1ff, sep = "x"))
head(d$interactioncontrasts)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m1 = lm(pollcred_DV_5~interactioncontrasts+
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
cld(r1b)
# another method, and gives same results as above lenghty, mnultistep code:
# but downside is that it does not show significance stars, 
# at least this gives me confidence (same results) that the warning message in above code can be ignored
lsmeans(r1, pairwise~manips_W2_lowVshighQuality*manips_w1ff, adjust="tukey")


r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

stargazer(r1, type = "text", out = "original_main_model.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 

plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality"),
                     title = "Perceived Credibility of Polls by Methodological Quality and Interventions",
                     axis.title = c("Interventions (W1)","Perceived Credibility of Polls (W2)"),
                     axis.labels = TRUE,   line.size = 2,
                     legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
                     colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.9) 

ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_5, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + 
  geom_boxplot(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("lightblue", "darkgray"),
                                                              labels=c('Low Quality', 
                                                                       'High Quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methods Quality and Trainings", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 


#  TIGER plot
ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_5, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + 
  geom_count(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("blue", "darkgray"),
                                                                                            labels=c('Low Quality', 
                                                                                                     'High Quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methodological Quality and Interventions", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
#  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 















################# ################ ################ ################ ################  moderation by individual differences

# subjective numeracy
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","subjnum_W1"))

plot_model(r1, type = "pred", terms = c("subjnum_W1", "manips_W2_lowVshighQuality", "manips_w1ff")) 

plot_model(r1, type = "pred", terms = c("subjnum_W1", "manips_W2_lowVshighQuality", "manips_w1ff"), 
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Subjective Numeracy Levels",
           axis.title = c("Subjective Numeracy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3, 
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7) 


# everyday science litearacy

table(d$esl_total01)

r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)

# use esl_total01_cat version for 3 graphs only
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)


plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","esl_total01"))

plot_model(r1, type = "pred", terms = c("esl_total01", "manips_W2_lowVshighQuality","manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Everyday Science Literacy Levels",
           axis.title = c("Everyday Science Literacy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)

# posthoc insights:
table(d$esl_total01)
d$esl_total01cat<-d$esl_total01
d$esl_total01cat[d$esl_total01cat<.51] <- 0
d$esl_total01cat[d$esl_total01cat>.50] <- 1
table(d$esl_total01cat)

d$interactioncontrasts <- with(d, interaction(manips_W2_lowVshighQuality, manips_w1ff, esl_total01cat, sep = "x"))
head(d$interactioncontrasts)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m1 = lm(pollcred_DV_5~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
cld(r1b)




# digital news litearacy
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
#plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","index_NewsLitBehave_W1"))

plot_model(r1, type = "pred", terms = c("index_NewsLitBehave_W1", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Digital News Literacy Levels",
           axis.title = c("Digital News Literacy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(.1,.7)



# education
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*educat01+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*educat01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
#plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","educat01"))

plot_model(r1, type = "pred", terms = c("educat01", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Education Levels",
           axis.title = c("Education Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)

# put in appendix as laternative visualization:
ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_5, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + facet_grid(d$educat01) +
  geom_boxplot(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("lightgray", "lightblue"),
                                                                                            labels=c('Low methods quality', 
                                                                                                     'High methods quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methods Quality, Trainings, and Education Levels", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 


# posthoc insights:
table(d$educat01)
d$educat01_Cat<-d$educat01
d$educat01_Cat[d$educat01_Cat<.51] <- 0
d$educat01_Cat[d$educat01_Cat>.50] <- 1
table(d$educat01_Cat)

d$interactioncontrasts <- with(d, interaction(manips_W2_lowVshighQuality, manips_w1ff, educat01_Cat, sep = "x"))
head(d$interactioncontrasts)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m1 = lm(pollcred_DV_5~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
cld(r1b)




## TRUST IN SCIENCE IS FOR APPENDIX:
# trust in science - USE index_trustinscinece_A_W2 
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_trustinscinece_A_W2+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_trustinscinece_A_W2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","index_trustinscinece_A_W2"))

plot_model(r1, type = "pred", terms = c("index_trustinscinece_A_W2", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nIndividuals' Trust in Scientists Levels",
           axis.title = c("Trust in Science","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.95)

## not index_trustinscinece_B_W2

r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_trustinscinece_B_W2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","index_trustinscinece_B_W2"))

plot_model(r1, type = "pred", terms = c("index_trustinscinece_B_W2", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nIndividuals' Trust in Science Levels",
           axis.title = c("Trust in Science","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.95)





















# Rq1 and Rq2

## vaccine
#baseline
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) # IMPORTANT, I cannot control "+manips_W2_covidVsAI" 
#because vax and AI are tested separately here
summary(r1)
#rq1
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_W2_lowVshighQuality"))
#rq2
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
#plot other way
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (COVID-19 Vaccine)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)
# testing significance of this pattern within inopculation conditions only
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*
          RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1==4,])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute",
                                        "manips_W2_lowVshighQuality"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality"),
           title = "Perceived Credibility of Polls by Methodological Quality and \nUnfavorable Poll Result (COVID-19 Vaccine) \nAmong Inoculation Group Only",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)


## AI
#baseline
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
#rq1
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_W2_lowVshighQuality"))
#rq2
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
#plot other way
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (AI)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)
# testing significance of this pattern within inopculation conditions only
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*
          RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1==4,])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute",
                                        "manips_W2_lowVshighQuality"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality"),
           title = "Perceived Credibility of Polls by Methodological Quality and \nUnfavorable Poll Result (AI) \nAmong Inoculation Group Only",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)

#### create appendix table for Rq1 and Rq2
# vax
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_vaxrisk_absolute*manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
# ai
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_AIrisk_absolute*manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)


# now test second-order misinformaiton (majority concerned about frequent serious side effects! vs plausible poll results) ?? a bit confusing
# just a split sample analysis for covid vs ai
table(d$manips_W2_covid_ConcernVsConfident)
# c19
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, 
        data=d[d$manips_W2_covid_ConcernVsConfident=="Concerned about Vaccine",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (COVID-19 Vaccine) \nAmong Polls showing Majority Concern (2nd Order Misinformation)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.8)

r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, 
        data=d[d$manips_W2_covid_ConcernVsConfident=="Confident about Vaccine",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, \nand Unfavorable Poll Result (COVID-19 Vaccine) Among Polls showing \nMajority Confidence about Vax Safety (Plausible Poll)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.8)



# AI regulation (still do it, although there is no 'second order misinfo' case here)
table(d$manips_W2_AIregulation_SupportVsOppose)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, 
        data=d[d$manips_W2_AIregulation_SupportVsOppose=="Oppose AI-Regulation",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (AI) \nAmong Polls showing Majority Oppose AI regulation",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(-.2,1)


r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, 
        data=d[d$manips_W2_AIregulation_SupportVsOppose=="Support AI-Regulation",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (AI) \nAmong Polls showing Majority Support AI regulation",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.8)















################# ################ ################ ################ ################  producing the results table for credibility findings:

# report baselines and H1 (control) in paper, but not put in table to simplify

r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d)
summary(r1)
r2 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r2)
r3 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*educat01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r3)
r4 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r4)
r5 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r5)
r6 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r6)
r7 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r7)
r8 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r8)

library(stargazer)
stargazer(r1, r2, r3, r4, r5, r6, r7, r8, type = "text", out = "Models.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))





##### APPENDIX - MAIN CREDIBILITY RESULTS BY EXCLUDING THE 5TH 'SCIENTIFIC' ITEM FROM THE CREDIBILITY SCALER 

r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d)
summary(r1)
r2 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r2)
r3 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*educat01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r3)
r4 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r4)
r5 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r5)
r6 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r6)
r7 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r7)
r8 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r8)

stargazer(r1, r2, r3, r4, r5, r6, r7, r8, type = "text", out = "Models_EXCLUDING_5THcredibilityITEM.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))







table(d$manips_W2_covidVsAI)


# main results - examining for heterogeneous effects among vax vs AI polls only

# vaccine polls only
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",])
summary(r1)
r2 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",]) 
summary(r2)
r3 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*educat01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",]) 
summary(r3)
r4 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",]) 
summary(r4)
r5 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",]) 
summary(r5)
r6 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",]) 
summary(r6)
r7 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",])
summary(r7)

# AI polls only
r8 = lm(pollcred_DV_5~manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",])
summary(r8)
r9 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",]) 
summary(r9)
r10 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*educat01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",]) 
summary(r10)
r11 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",]) 
summary(r11)
r12 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",]) 
summary(r12)
r13 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",]) 
summary(r13)
r14 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",])
summary(r14)

stargazer(r1, r2, r3, r4, r5, r6, r7, type = "text", out = "Models_VaxOnly.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
stargazer(r8, r9, r10, r11, r12, r13, r14, type = "text", out = "Models_AIOnly.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))





##### interference tests on main findings - credibility

##### 1. Vaccine Interference Main Effects, among all polls
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+interfere_vax+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
##### 2. Vaccine Interference Interaction Effects, among all polls
r2 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*interfere_vax+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r2)
##### 3. Vaccine Interference Main Effects, among vaccine polls only
r3 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+interfere_vax+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",]) 
summary(r3)
##### 4. Vaccine Interference Interaction Effects, among vaccine polls only
r4 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*interfere_vax+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",]) 
summary(r4)

stargazer(r1, r2, r3, r4, type = "text", out = "Interference_Vaccine.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


##### 5. AI Interference Main Effects, among all polls
r5 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+interfere_ai+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r5)
##### 6. AI Interference Interaction Effects, among all polls
r6 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*interfere_ai+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r6)
##### 7. AI Interference Main Effects, among AI polls only
r7 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+interfere_ai+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",]) 
summary(r7)
##### 8. AI Interference Interaction Effects, among AI polls only
r8 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*interfere_ai+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",]) 
summary(r8)

stargazer(r5, r6, r7, r8, type = "text", out = "Interference_AI.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


##### 9. Poll Interference Main Effects, among all polls
r9 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+interfere_poll+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r9)
##### 10. Poll Interference Interaction Effects, among all polls
r10 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*interfere_poll+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r10)
stargazer(r9, r10, type = "text", out = "Interference_POLLs.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))








# one significant moderation effect for interference - AI interference on active literacy intervention: visualize

r8 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*interfere_ai+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_covidVsAI=="AI Regulation Policy",]) 
summary(r8)

plot_model(r8, type = "pred", terms = c("interfere_ai","manips_W2_lowVshighQuality","manips_w1ff"),
           title = "Perceived Credibility of AI Issue Polls by Methodological Quality, Interventions, and AI Interference \n(Interference: Exposure to AI Related Informatino and News from W1 to W2)",
           axis.title = c("Interventions (W1)","Perceived Credibility of AI Issue Polls (W2)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.9) 














################ ################# ################ ################ ################  PERCEPTIONS AND INTENTIONS DVS...
# PRIORITIZE DIFFERENCE SCORES, CROSS-SECTINOAL ONES CAN GO TO APPENDIX....
# vax and ai dv
#crossect
d$W2_posttest_INDEX_vax_risk1_W2
d$W2_posttest_INDEX_vaxPO_risk1_W2
d$W2_post_VaxPerceptPOpercent_01
d$W2_post_VaxIntention_01
d$W2_post_Vax_Positivity_01
d$W2_posttest_INDEX_AI_risk1_W2
d$W2_posttest_INDEX_aiPO_risk1_W2
d$W2_post_aiPerceptPOpercent_01
d$W2_post_AI_PolicyView_01
d$W2_post_ai_Positivity_01

#diff scores
d$DIFFw2w1_INDEX_vax_risk1
d$DIFFw2w1_INDEX_vaxPO_risk1
d$DIFFw2w1_VaxPerceptPOpercent
d$DIFFw2w1_VaxIntention
d$DIFFw2w1_Vax_Positivity
d$DIFFw2w1_INDEX_AI_risk1
d$DIFFw2w1_INDEX_aiPO_risk1
d$DIFFw2w1_aiPerceptPOpercent_01
d$DIFFw2w1_AI_PolicyView_01
d$DIFFw2w1_ai_Positivity_01





#### DIFFERENCE SCORES - MORE ROBUST AND CONVERVATIVE
# for risk and PO perception outcomes, you have to control for directionality 
d$manips_W2_covid_ConcernVsConfident
d$manips_W2_AIregulation_SupportVsOppose

########## VACCINE RESULTS - 5 OUTCOMES MAIN TESTS (DO NOT INCLUDE INDIVIDUAL DIFFERENCE MODERATOTS YET)

##### 1) DIFFw2w1_INDEX_vax_risk1
#quality
r1 = aov(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

##### 2) DIFFw2w1_INDEX_vaxPO_risk1
#quality
r1 = aov(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Public Opinion Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Public Opinion Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

##### 3) DIFFw2w1_VaxPerceptPOpercent
#quality
r1 = aov(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Public Opinion %-Perceptions (W2-W1) by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Public Opinion %-Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 16)) +
  theme(text = element_text(size = 15))

# posthoc test for linear model:
d$interactioncontrasts2 <- with(d, interaction(manips_W2_lowVshighQuality, manips_w1ff, manips_W2_covid_ConcernVsConfident, sep = "x"))
head(d$interactioncontrasts2)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m2 = lm(DIFFw2w1_VaxPerceptPOpercent~interactioncontrasts2+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r2b <- glht(m2, linfct = mcp(interactioncontrasts2 = "Tukey"))
summary(r2b)
cld(r2b)
# another method, WOW one shot, and gives same results as above lenghty, mnultistep code:
# but downside is that it does not show significance stars, 
# at least this gives me confidence (same results) that the warning message in above code can be ignored
lsmeans(r1, pairwise~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, adjust="tukey")
# RESULTS: results showed  2 notable pairwise differences




##### 4) DIFFw2w1_VaxIntention
#quality
r1 = aov(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in COVID-19 Vaccination Intentions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Intentions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 5) DIFFw2w1_Vax_Positivity
#quality
r1 = aov(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff+manips_W2_covid_ConcernVsConfident+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in COVID-19 Vaccine Positivity (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Positivity (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 




########## ARTIFICIAL INTELLIGENCE RESULTS - 5 OUTCOMES MAIN TESTS (DO NOT INCLUDE INDIVIDUAL DIFFERENCE MODERATOTS YET)


##### 1) DIFFw2w1_INDEX_AI_risk1
#quality
r1 = aov(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Perceptions (W2-W1) by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 16)) +
  theme(text = element_text(size = 15))

# posthoc test for linear model:
d$interactioncontrasts3 <- with(d, interaction(manips_W2_lowVshighQuality, manips_w1ff, manips_W2_AIregulation_SupportVsOppose, sep = "x"))
head(d$interactioncontrasts3)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m3 = lm(DIFFw2w1_INDEX_AI_risk1~interactioncontrasts3+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r3b <- glht(m3, linfct = mcp(interactioncontrasts3 = "Tukey"))
summary(r3b)
cld(r3b)
# another method, and gives same results as above lenghty, mnultistep code:
# but downside is that it does not show significance stars, 
# at least this gives me confidence (same results) that the warning message in above code can be ignored
lsmeans(r1, pairwise~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, adjust="tukey")
# RESULTS: no pairwise is significant, 




##### 2) d$DIFFw2w1_INDEX_aiPO_risk1
#quality
r1 = aov(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Public Opinion Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Public Opinion Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 3) d$DIFFw2w1_aiPerceptPOpercent_01
#quality
r1 = aov(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Public Opinion %-Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Public Opinion %-Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

# posthoc test for linear model:
d$interactioncontrasts4 <- with(d, interaction(manips_W2_lowVshighQuality, manips_w1ff, manips_W2_AIregulation_SupportVsOppose, sep = "x"))
head(d$interactioncontrasts4)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m4 = lm(DIFFw2w1_aiPerceptPOpercent_01~interactioncontrasts4+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r4b <- glht(m4, linfct = mcp(interactioncontrasts4 = "Tukey"))
summary(r4b)
cld(r4b)
# another method, WOW one shot, and gives same results as above lenghty, mnultistep code:
# but downside is that it does not show significance stars, 
# at least this gives me confidence (same results) that the warning message in above code can be ignored
lsmeans(r1, pairwise~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, adjust="tukey")





##### 4) d$DIFFw2w1_AI_PolicyView_01
#quality
r1 = aov(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Regulation Policy Support (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Regulation Policy Support (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

# posthoc test for linear model:
d$interactioncontrasts5 <- with(d, interaction(manips_W2_lowVshighQuality, manips_w1ff, manips_W2_AIregulation_SupportVsOppose, sep = "x"))
head(d$interactioncontrasts5)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m5 = lm(DIFFw2w1_AI_PolicyView_01~interactioncontrasts5+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r5b <- glht(m5, linfct = mcp(interactioncontrasts5 = "Tukey"))
summary(r5b)
cld(r5b)
# another method, WOW one shot, and gives same results as above lenghty, mnultistep code:
# but downside is that it does not show significance stars, 
# at least this gives me confidence (same results) that the warning message in above code can be ignored
lsmeans(r1, pairwise~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, adjust="tukey")



##### 5) d$DIFFw2w1_ai_Positivity_01
#quality
r1 = aov(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Positivity (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Positivity (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 








#### REGRESSION TABLE FOR ALL NON-CREDIBILITY MAIN MANUSCRIPT OUTCOMES - DIFF SCORES 
#### MAIN EFFECTS MODELS
## ALL VAX 
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_VaxIntention~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_Vax_Positivity~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_Vax_main_PAPER.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
## ALL AI
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_AI_main_PAPER.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
#### INTERACTION EFFECTS MODELS
## ALL VAX 
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_VaxIntention~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_Vax_Positivity~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_Vax_interact_PAPER.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
## ALL AI
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_AI_interact_PAPER.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))








#### REGRESSION TABLE FOR ALL NON-CREDIBILITY MAIN MANUSCRIPT OUTCOMES ------ NO CONTROLS AT ALL VERSION
#### MAIN EFFECTS MODELS
## ALL VAX 
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff, data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_VaxIntention~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_Vax_Positivity~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_Vax_main_NO_CONTROLS.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
## ALL AI
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff, data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_AI_main_NO_CONTROLS.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
#### INTERACTION EFFECTS MODELS
## ALL VAX 
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff, data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_VaxIntention~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_Vax_Positivity~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_Vax_interact_NO_CONTROLS.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
## ALL AI
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff, data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_AI_interact_NO_CONTROLS.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))







#### REGRESSION TABLE FOR ALL NON-CREDIBILITY MAIN MANUSCRIPT OUTCOMES ------ ALL CONTROLS VERSION


d$Sex_X <- d$Sex_ # to go around a stargazer code issue (variable name cannot end with "_")

#### MAIN EFFECTS MODELS
## ALL VAX 
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r2)
r3 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r3)
r4 = lm(DIFFw2w1_VaxIntention~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r4)
r5 = lm(DIFFw2w1_Vax_Positivity~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_Vax_main_ALLCONTROLS.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
## ALL AI
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r2)
r3 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r3)
r4 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r4)
r5 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_AI_main_ALLCONTROLS.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
#### INTERACTION EFFECTS MODELS
## ALL VAX 
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d)
summary(r1)
r2 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r2)
r3 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r3)
r4 = lm(DIFFw2w1_VaxIntention~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r4)
r5 = lm(DIFFw2w1_Vax_Positivity~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_Vax_interact_ALLCONTROLS.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
## ALL AI
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Public Opinion Perceptions (W2-W1) by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Public Opinion Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 
r2 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r2)
r3 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r3)
r4 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r4)
r5 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + 
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 , data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_AI_interact_ALLCONTROLS.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))



















################## ################ ################ ################ ################  moderators for non-credibility diff-score outcomes



## d$DIFFw2w1_INDEX_vax_risk1 by all moderators:
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
r2 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_1.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


# d$DIFFw2w1_INDEX_vaxPO_risk1 by all moderators
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
r2 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4) # SIGNIFICANT but not persistent and very small
#plot_model(r1, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality","manips_w1ff"))
r5 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_2.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


# d$DIFFw2w1_VaxPerceptPOpercent  by all moderators:
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
r2 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4) # SIGNIFICANT , THIS IS NOTEWORTHY
#plot_model(r1, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality","manips_w1ff"))
r5 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_3.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


# d$DIFFw2w1_VaxIntention  by all moderators:
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1) # SIGNIFICANT , THIS IS NOTEWORTHY
plot_model(r1, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality","manips_w1ff"))
r2 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_4.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))

# d$DIFFw2w1_Vax_Positivity  by all moderators:
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
r2 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2) ### SIGNIFICANT notworthy
#plot_model(r1, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality","manips_w1ff"))
r3 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_5.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


# d$DIFFw2w1_INDEX_AI_risk1 by all moderators:
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) # SIGNIFICANT
summary(r1) ## WOW SIGNIFICANT NOTEWORHY 3-WAY
#plot_model(r1, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality","manips_w1ff"))
# WOW, un-treated/control group who has high subjective numeracy were moved by high-quality polls! their AI risk perception increased... but not a big deal
r2 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) # SIGNIFICANT
summary(r3) ### SIGNIFICANT, VERY CLEAR PATTERN, UNTREATED UNTRAINED PEOPLE ARE GULLIABLE IN RISK PERCEPTIONS...
#plot_model(r1, type = "pred", terms = c("index_NewsLitBehave_W1","manips_W2_lowVshighQuality","manips_w1ff"))
r4 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_6.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


# d$DIFFw2w1_INDEX_aiPO_risk1  by all moderators:
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) # SIGNIFICANT
summary(r1) #### SIGNIFICANT
#plot_model(r1, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality","manips_w1ff"))
r2 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_7.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))

# d$DIFFw2w1_aiPerceptPOpercent_01  by all moderators:
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) # 
summary(r1)
r2 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_8.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))

# d$DIFFw2w1_AI_PolicyView_01  by all moderators:
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
r2 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_9.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))

# d$DIFFw2w1_ai_Positivity_01  by all moderators:
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
r2 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2) ## SIGNIFICANT
#plot_model(r1, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality","manips_w1ff"))
r3 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)

stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_IndDiffModerators_10.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


















#### REGRESSION TABLE FOR ALL NON-CREDIBILITY MAIN MANUSCRIPT OUTCOMES - CROSSLAGGED VERSIONS (W2 OUTCOME, CONTROLLING FOR W1 TEST)
########################## ################ ################ ################  CROSSSECTIONAL SCORES FOR NON-CREDIBILTIY OUTCOMES

# CROSSECTIONALS

r1 = lm(W2_post_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+pre_AI_PolicyView_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose","manips_w1ff"))

#crossect
d$W2_posttest_INDEX_vax_risk1_W2 # null controlling for pretest 
d$W2_posttest_INDEX_vaxPO_risk1_W2 # null controlling for pretest 
d$W2_post_VaxPerceptPOpercent_01 # SIGNIFICANT, same result as expected with difference score approach above
d$W2_post_VaxIntention_01 # null controlling for pretest - some significance but doesnt make sense
d$W2_post_Vax_Positivity_01 # null controlling for pretest 

d$W2_posttest_INDEX_AI_risk1_W2  # SIGNIFICANT some expected effect high quality polls matter depending on poll directionality among inoculation group... 
d$W2_posttest_INDEX_aiPO_risk1_W2 # null controlling for pretest 
d$W2_post_aiPerceptPOpercent_01 # null controlling for pretest 
d$W2_post_AI_PolicyView_01 # # null controlling for pretest - some significance but doesnt make sense
d$W2_post_ai_Positivity_01 # null controlling for pretest - some significance but doesnt make sense

#PRE-TEST CONTROLS
d$pretest_INDEX_vax_risk1_W1 
d$pretest_INDEX_vaxPO_risk1_W1 
d$pre_VaxPerceptPOpercent_01     
d$pre_VaxIntention_01
d$pre_Vax_Positivity_01 

d$pretest_INDEX_AI_risk1_W1
d$pretest_INDEX_aiPO_risk1_W1
d$pre_aiPerceptPOpercent_01 
d$pre_AI_PolicyView_01 
d$pre_ai_Positivity_01


# vax
r1 = aov(W2_post_VaxPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident+pre_VaxPerceptPOpercent_01+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = lm(W2_post_VaxPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+pre_VaxPerceptPOpercent_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine PO% (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

# ai
r1 = aov(W2_posttest_INDEX_AI_risk1_W2~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose+pretest_INDEX_AI_risk1_W1+
           Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = lm(W2_posttest_INDEX_AI_risk1_W2~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+pretest_INDEX_AI_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "AI Risk Perceptions (W2) by Methodological Quality and Interventions while Controlling for W1 Pretest AI Risk Perceptions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


#POST AS DV, PRETEST AS IV
#d$W2_posttest_INDEX_vax_risk1_W2, d$pretest_INDEX_vax_risk1_W1 
#d$W2_posttest_INDEX_vaxPO_risk1_W2, d$pretest_INDEX_vaxPO_risk1_W1 
#d$W2_post_VaxPerceptPOpercent_01, d$pre_VaxPerceptPOpercent_01  
#d$W2_post_VaxIntention_01, d$pre_VaxIntention_01 
#d$W2_post_Vax_Positivity_01, d$pre_Vax_Positivity_01 

#d$W2_posttest_INDEX_AI_risk1_W2, d$pretest_INDEX_AI_risk1_W1
#d$W2_posttest_INDEX_aiPO_risk1_W2, d$pretest_INDEX_aiPO_risk1_W1 
#d$W2_post_aiPerceptPOpercent_01, d$pre_aiPerceptPOpercent_01 
#d$W2_post_AI_PolicyView_01, d$pre_AI_PolicyView_01
#d$W2_post_ai_Positivity_01, d$pre_ai_Positivity_01


#### MAIN EFFECTS MODELS
## ALL VAX 
r1 = lm(W2_posttest_INDEX_vax_risk1_W2~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+pretest_INDEX_vax_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(W2_posttest_INDEX_vaxPO_risk1_W2~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+pretest_INDEX_vaxPO_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(W2_post_VaxPerceptPOpercent_01~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+pre_VaxPerceptPOpercent_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(W2_post_VaxIntention_01~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+pre_VaxIntention_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(W2_post_Vax_Positivity_01~manips_W2_covid_ConcernVsConfident+manips_W2_lowVshighQuality+manips_w1ff+pre_Vax_Positivity_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_Vax_main_CROSSLAGGED.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
## ALL AI
r1 = lm(W2_posttest_INDEX_AI_risk1_W2~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+pretest_INDEX_AI_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(W2_posttest_INDEX_aiPO_risk1_W2~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+pretest_INDEX_aiPO_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(W2_post_aiPerceptPOpercent_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+pre_aiPerceptPOpercent_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(W2_post_AI_PolicyView_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+pre_AI_PolicyView_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(W2_post_ai_Positivity_01~manips_W2_AIregulation_SupportVsOppose+manips_W2_lowVshighQuality+manips_w1ff+pre_ai_Positivity_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_AI_main_CROSSLAGGED.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
#### INTERACTION EFFECTS MODELS
## ALL VAX 
r1 = lm(W2_posttest_INDEX_vax_risk1_W2~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+pretest_INDEX_vax_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(W2_posttest_INDEX_vaxPO_risk1_W2~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+pretest_INDEX_vaxPO_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(W2_post_VaxPerceptPOpercent_01~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+pre_VaxPerceptPOpercent_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(W2_post_VaxIntention_01~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+pre_VaxIntention_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(W2_post_Vax_Positivity_01~manips_W2_covid_ConcernVsConfident*manips_W2_lowVshighQuality*manips_w1ff+pre_Vax_Positivity_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_Vax_interact_CROSSLAGGED.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))
## ALL AI
r1 = lm(W2_posttest_INDEX_AI_risk1_W2~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+pretest_INDEX_AI_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(W2_posttest_INDEX_aiPO_risk1_W2~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+pretest_INDEX_aiPO_risk1_W1+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
r3 = lm(W2_post_aiPerceptPOpercent_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+pre_aiPerceptPOpercent_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
r4 = lm(W2_post_AI_PolicyView_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+pre_AI_PolicyView_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
r5 = lm(W2_post_ai_Positivity_01~manips_W2_AIregulation_SupportVsOppose*manips_W2_lowVshighQuality*manips_w1ff+pre_ai_Positivity_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
stargazer(r1, r2, r3, r4, r5, type = "text", out = "NonCredOutcomes_AI_interact_CROSSLAGGED.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))























################## ################ ################  pre-registered as exploratory 

### QUESTION-1: DID GENERAL EVALUATIONS OF POLLS Change DUE TO INTERVENTIONS?
### QUESTION-2: DID GENERAL PREEXISTING PRETEST EVALUATIONS OF POLLS MDOERATE THE EFFECTS OF INTERVENTIONS? NO

### QUESTION-1: DID GENERAL EVALUATIONS OF POLLS Change DUE TO INTERVENTIONS? 
#GENERAL VIEWS OF POLLS AS AN OUTCOME VARIABLE (DIFF SCORE)

# 6 very convenient variables:

d$index3item_generalpollcredibility_W2_manipcheck # null
d$Diff_W2minusW1pretest_credible_pollsInGeneral #null
d$index_pollgeneralConcern3items_W2 # null
d$Diff_W2minusW1pretest_concern1_pollsInGeneral # null
d$index_poll_efficacy_W2 # null
d$Diff_W2minusW1pretest_efficacy_pollsInGeneral #NULL


# makes sense to look at diff-score distributions too, but this might be driven attrition
t.test(d$Diff_W2minusW1pretest_credible_pollsInGeneral)
#t.test(d[d$manips_w1ff=="Int3: Inoculation (W1)",]$Diff_W2minusW1pretest_credible_pollsInGeneral)
t.test(d$Diff_W2minusW1pretest_concern1_pollsInGeneral)
t.test(d$Diff_W2minusW1pretest_efficacy_pollsInGeneral)

r1 = lm(index3item_generalpollcredibility_W2_manipcheck~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

r2 = lm(Diff_W2minusW1pretest_credible_pollsInGeneral~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r2)
plot_model(r2, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

r3 = lm(index_pollgeneralConcern3items_W2~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r3)
plot_model(r3, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

r4 = lm(Diff_W2minusW1pretest_concern1_pollsInGeneral~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
plot_model(r4, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

r5 = lm(index_poll_efficacy_W2~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
plot_model(r5, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

r6 = lm(Diff_W2minusW1pretest_efficacy_pollsInGeneral~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r6)
plot_model(r6, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

stargazer(r1, r2, r3, r4, r5, r6, type = "text", out = "DidInterventionsChangeGeneralPollEvals.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))



### QUESTION-2: DID GENERAL PREEXISTING PRETEST EVALUATIONS OF POLLS MDOERATE THE EFFECTS OF INTERVENTIONS? NO

# PRETEST CREDIBLE d$pre_credible_01 
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*pre_credible_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("pre_credible_01", "manips_W2_lowVshighQuality", "manips_w1ff"), 
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals'  Preexisting Credibility Perceptions of Polls in General",
           axis.title = c("Pre-existing General Evals. of Polls ","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3, 
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,1) 

# PRETEST EFFICACY
r2 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*pre_efficacy1_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r2)
plot_model(r2, type = "pred", terms = c("pre_efficacy1_01", "manips_W2_lowVshighQuality", "manips_w1ff"), 
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals'  Preexisting Efficacy about Polls",
           axis.title = c("Pre-existing Efficacy about Polls ","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3, 
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,1) 


# PRETEST CONCERN
r3 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*pre_concern1_01+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r3)
plot_model(r3, type = "pred", terms = c("pre_concern1_01", "manips_W2_lowVshighQuality", "manips_w1ff"), 
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals'  Preexisting Concern about Polls",
           axis.title = c("Pre-existing Concern about Polls ","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3, 
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,1) 

stargazer(r1, r2, r3, type = "text", out = "DidPretestGeneralPollEvalsModerateInterventions.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))


























































































################################ ################ ################ ################  
#### 3_ Manuscript MODELS: INCLUDING ALL SORTS OF ADDITIONAL CONTROLS
################################ ################ ################ ################  

Age_Years + Sex_ + Chinese01 + Malay + Indian + OtherRace +
  liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
  pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
  subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
  W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
  sideEffectSeverity + experienceAI_01 +
  interfere_poll + interfere_vax + interfere_ai
# OtherRace excluded as reference
# manips_W2_covidVsAI is excluded from model 7 and 8 (unfavorable result moderation)


################################ ################ ################ ################  1) CREDIBILITY

#  I have to look at it only among W1 control too (H1), because most are from interventions:
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality+ 
           Age_Years + Sex_ + Chinese01 + Malay + Indian + OtherRace +
           liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
           pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
           subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
           W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
           sideEffectSeverity + experienceAI_01 +
           interfere_poll + interfere_vax + interfere_ai, data=d[d$manips_w1==1,])
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality+ 
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d[d$manips_w1==1,])
summary(r1)
# method quality matter OVERALL but this is driven by interventions, as above we show that among control there is no such effect!
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality+
           Age_Years + Sex_ + Chinese01 + Malay + Indian + OtherRace +
           liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
           pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
           subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
           W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
           sideEffectSeverity + experienceAI_01 +
           interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r1)
TukeyHSD(r1)
# method quality mattering interact with trainings!
r1 = aov(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff +
         Age_Years + Sex_ + Chinese01 + Malay + Indian + OtherRace +
           liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
           pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
           subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
           W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
           sideEffectSeverity + experienceAI_01 +
           interfere_poll + interfere_vax + interfere_ai, 
         data=d) 
summary(r1)

# great contrast resource using lm: https://stats.oarc.ucla.edu/r/faq/how-can-i-test-contrasts-in-r/
#install.packages("multcomp")
library(multcomp)
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff +
          Age_Years + Sex_ + Chinese01 + Malay + Indian + OtherRace +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)

plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality"),
           title = "Perceived Credibility of Polls by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.9) 

ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_5, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + 
  geom_boxplot(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("lightblue", "darkgray"),
                                                                                            labels=c('Low Quality', 
                                                                                                     'High Quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methods Quality and Trainings", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 


# my TIGER plot
ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_5, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + 
  geom_count(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("blue", "darkgray"),
                                                                                          labels=c('Low Quality', 
                                                                                                   'High Quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methodological Quality and Interventions", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  #  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 




################# ################ ################ ################ ################  moderation by individual differences

# subjective numeracy
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("subjnum_W1", "manips_W2_lowVshighQuality", "manips_w1ff"), 
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Subjective Numeracy Levels",
           axis.title = c("Subjective Numeracy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3, 
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7) 

# everyday science litearacy
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
          Age_Years + Sex_ + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("esl_total01", "manips_W2_lowVshighQuality","manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Everyday Science Literacy Levels",
           axis.title = c("Everyday Science Literacy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)

# digital news litearacy
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("index_NewsLitBehave_W1", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Digital News Literacy Levels",
           axis.title = c("Digital News Literacy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(.1,.7)

# education
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*educat01+
          Age_Years + Sex_ + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("educat01", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Education Levels",
           axis.title = c("Education Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)



## TRUST IN SCIENCE IS FOR APPENDIX:
# trust in science - USE index_trustinscinece_A_W2 not index_trustinscinece_B_W2
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_trustinscinece_A_W2+
          Age_Years + Sex_ + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("index_trustinscinece_A_W2", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nIndividuals' Trust in Science Levels",
           axis.title = c("Trust in Science","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.95)



### PUT INTO APPENDIX LIKE TRUST IN SCIENCE, PREXISTING TRUST LEVELS IN POLLS IN GENERAL DID NOT CONDITION THE EFFECTS OF INTERVENTIONS":
# d$pre_credible_01 
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*pre_credible_01+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("pre_credible_01", "manips_W2_lowVshighQuality", "manips_w1ff"), 
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Subjective Numeracy Levels",
           axis.title = c("Subjective Numeracy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3, 
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,1) 




# Rq1 and Rq2

## vaccine ---- have to remove  + manips_W2_covidVsAI as this is only vax or AI, issue specific
#baseline
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) # IMPORTANT, I cannot control "+manips_W2_covidVsAI" 
#because vax and AI are tested separately here
summary(r1)
#rq1
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_W2_lowVshighQuality"))
#rq2
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r1)
#plot other way
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (COVID-19 Vaccine)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)

## AI
#baseline
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r1)
#rq1
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_W2_lowVshighQuality"))
#rq2
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r1)
#plot other way
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (AI)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.1,.7)

# now test second-order misinformaiton (majority concerned about frequent serious side effects! vs plausible poll results) ?? a bit confusing
# just a split sample analysis for covid vs ai
table(d$manips_W2_covid_ConcernVsConfident)
# c19
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax, 
        data=d[d$manips_W2_covid_ConcernVsConfident=="Concerned about Vaccine",])
summary(r1)

plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (COVID-19 Vaccine) \nAmong Polls showing Majority Concern (2nd Order Misinformation)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,1)

r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Sex_ + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, 
        data=d[d$manips_W2_covid_ConcernVsConfident=="Confident about Vaccine",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, \nand Unfavorable Poll Result (COVID-19 Vaccine) Among Polls showing \nMajority Confidence about Vax Safety (Plausible Poll)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,1)

#ai - BUT NO NEED TO TEST THIS FOR AI POLLS, SINCE BOTH CAN BE PLAUSIBLE, IT IS NOT LIKE COVID SECOND ORDER MISINFORMATION SITUATION ABOUT RISK PERCEPTIONS REPORTING IN POLL








################# ################ ################ ################ ################  producing the results table for credibility findings:- all controls

# stargazer does not want underscored-ending variable names, so lets change them: Sex_ 

d$Sex_X <- d$Sex_ 


r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r1)
r2 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r2)
r3 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*educat01+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r3)
r4 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r4)
r5 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r5)
r6 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 + manips_W2_covidVsAI +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r6)
r7 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r7)
r8 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Sex_X + Chinese01 + Malay + Indian + 
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d)
summary(r8)

library(stargazer)
stargazer(r1, r2, r3, r4, r5, r6, r7, r8, type = "text", out = "ModelsALLCONTROL.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))





#### DIFFERENCE SCORES - MORE ROBUST AND CONVERVATIVE
# for risk and PO perception outcomes, you have to control for directionality 
d$manips_W2_covid_ConcernVsConfident
d$manips_W2_AIregulation_SupportVsOppose

########## VACCINE RESULTS - 5 OUTCOMES MAIN TESTS (DO NOT INCLUDE INDIVIDUAL DIFFERENCE MODERATOTS YET)

##### 1) DIFFw2w1_INDEX_vax_risk1
#quality X intervention
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

##### 2) DIFFw2w1_INDEX_vaxPO_risk1
#quality X intervention
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Public Opinion Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Public Opinion Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

##### 3) DIFFw2w1_VaxPerceptPOpercent
#quality X intervention
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Public Opinion %-Perceptions (W2-W1) by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Public Opinion %-Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 16)) +
  theme(text = element_text(size = 15))

##### 4) DIFFw2w1_VaxIntention
#quality X intervention
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in COVID-19 Vaccination Intentions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Intentions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 5) DIFFw2w1_Vax_Positivity
#quality X intervention
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in COVID-19 Vaccine Positivity (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Positivity (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 




########## ARTIFICIAL INTELLIGENCE RESULTS - 5 OUTCOMES MAIN TESTS (DO NOT INCLUDE INDIVIDUAL DIFFERENCE MODERATOTS YET)


##### 1) DIFFw2w1_INDEX_AI_risk1
#quality X intervention
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Perceptions (W2-W1) by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 16)) +
  theme(text = element_text(size = 15))


##### 2) d$DIFFw2w1_INDEX_aiPO_risk1
#quality X intervention
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Public Opinion Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Public Opinion Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 3) d$DIFFw2w1_aiPerceptPOpercent_01
#quality X intervention
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose +
        Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Public Opinion %-Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Public Opinion %-Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 4) d$DIFFw2w1_AI_PolicyView_01
#quality X intervention
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Sex_X + Chinese01 + Malay + Indian +
          liberalimputed01 + Income01 + educat01 + pretest_INDEX_pollInterest_W1 +
          pretest_INDEX_vax_risk1_W1 + pretest_INDEX_AI_risk1_W1 + 
          subjnum_W1 + index_NewsLitBehave_W1 + esl_total01 + index_trustinscinece_A_W2 + 
          W2_index_TradNews_W1 + W2_index_SocialNews_W1 + W2_index_MessAppNews_W1 +
          sideEffectSeverity + experienceAI_01 +
          interfere_poll + interfere_vax + interfere_ai, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Regulation Policy Support (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Regulation Policy Support (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 5) d$DIFFw2w1_ai_Positivity_01
#quality X intervention
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Positivity (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Positivity (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 





























########### ########### ########### ########### ########### ########### ########### 
###########


###########  APPENDIX - MAIN MODELS WITHOUT ANY CONTROL VARIABLES




################################ ################ ################ ################  1) CREDIBILITY

d$pollcred_DV_4
d$pollcred_DV_5 # appendix because 5th item may be considered as too obvious by some 

#  I have to look at it only among W1 control too (H1), because most are from interventions:
r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality, data=d[d$manips_w1==1,])
summary(r1)
TukeyHSD(r1)
# method quality matter OVERALL
r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality, data=d)
summary(r1)
TukeyHSD(r1)
# contrasting control vs all interventions combined
r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality, data=d[d$manips_w1>1,])
#r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1_C1vsC234, data=d)
summary(r1)
TukeyHSD(r1)

table(d$OtherRace)

# method quality mattering interact with trainings!
r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff+Age_Years, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality"),
           title = "Perceived Credibility of Polls by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_4, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + 
  geom_boxplot(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("lightblue", "darkgray"),
                                                                                            labels=c('Low methods quality', 
                                                                                                     'High methods quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methods Quality and Trainings", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 


# my ZEBRA plot
ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_4, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + 
  geom_count(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("lightblue", "darkgray"),
                                                                                          labels=c('Low methods quality', 
                                                                                                   'High methods quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methodological Quality and Interventions", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  #  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 


ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_4, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + 
  geom_hex(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("lightblue", "darkgray"),
                                                                                        labels=c('Low methods quality', 
                                                                                                 'High methods quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methods Quality and Trainings", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 

























################# ################ ################ ################ ################  moderation by individual differences

# subjective numeracy
r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","subjnum_W1"))

plot_model(r1, type = "pred", terms = c("subjnum_W1", "manips_W2_lowVshighQuality", "manips_w1ff"))

plot_model(r1, type = "pred", terms = c("subjnum_W1", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Subjective Numeracy Levels",
           axis.title = c("Subjective Numeracy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3, 
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)


# everyday science litearacy

table(d$esl_total01)

r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*esl_total01, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*esl_total01, data=d) 
summary(r1)

# use esl_total01_cat version for 3 graphs only
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*esl_total01, data=d) 
summary(r1)

plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","esl_total01"))

plot_model(r1, type = "pred", terms = c("esl_total01", "manips_W2_lowVshighQuality","manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Everyday Science Literacy Levels",
           axis.title = c("Everyday Science Literacy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)


# digital news litearacy
r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1, data=d) 
summary(r1)
#plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","index_NewsLitBehave_W1"))

plot_model(r1, type = "pred", terms = c("index_NewsLitBehave_W1", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Digital News Literacy Levels",
           axis.title = c("Digital News Literacy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)


# education
r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*educat01, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*educat01, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","educat01"))

plot_model(r1, type = "pred", terms = c("educat01", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality, Interventions, and \nIndividuals' Education Levels",
           axis.title = c("Education Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)

# put in appendix as laternative visualization:
ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_4, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + facet_grid(d$educat01) +
  geom_boxplot(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("lightgray", "lightblue"),
                                                                                            labels=c('Low methods quality', 
                                                                                                     'High methods quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methods Quality and Trainings", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 

## TRUST IN SCIENCE IS FOR APPENDIX:
# trust in science - USE index_trustinscinece_A_W2 not index_trustinscinece_B_W2
r1 = aov(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*index_trustinscinece_A_W2, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*index_trustinscinece_A_W2, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality","index_trustinscinece_A_W2"))

plot_model(r1, type = "pred", terms = c("index_trustinscinece_A_W2", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nIndividuals' Trust in Science Levels",
           axis.title = c("Trust in Science","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.95)




# Rq1 and Rq2

## vaccine
#baseline
r1 = lm(pollcred_DV_4~RseenAttitudeInconsistentPO_vaxrisk_absolute, data=d)
summary(r1)
#rq1
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_vaxrisk_absolute, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_W2_lowVshighQuality"))
#rq2
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
#plot other way
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (COVID-19 Vaccine)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)
# testing significance of this pattern within inopculation conditions only
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*
          RseenAttitudeInconsistentPO_vaxrisk_absolute, data=d[d$manips_w1==4,])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute",
                                        "manips_W2_lowVshighQuality"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality"),
           title = "Perceived Credibility of Polls by Methodological Quality and \nUnfavorable Poll Result (COVID-19 Vaccine) \nAmong Inoculation Group Only",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)


## AI
r1 = lm(pollcred_DV_4~RseenAttitudeInconsistentPO_AIrisk_absolute, data=d)
summary(r1)
#rq1
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_AIrisk_absolute, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_W2_lowVshighQuality"))
#rq2
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute, data=d)
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
#plot other way
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (AI)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)
# testing significance of this pattern within inopculation conditions only
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*
          RseenAttitudeInconsistentPO_AIrisk_absolute, data=d[d$manips_w1==4,])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute",
                                        "manips_W2_lowVshighQuality"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality"),
           title = "Perceived Credibility of Polls by Methodological Quality and \nUnfavorable Poll Result (AI) \nAmong Inoculation Group Only",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)



# now test second-order misinformaiton (majority concerned about frequent serious side effects! vs plausible poll results) ?? a bit confusing
# just a split sample analysis for covid vs ai
table(d$manips_W2_covid_ConcernVsConfident)
# c19
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute, 
        data=d[d$manips_W2_covid_ConcernVsConfident=="Concerned about Vaccine",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (COVID-19 Vaccine) \nAmong Polls showing Majority Concern (2nd Order Misinformation)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)

r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute, 
        data=d[d$manips_W2_covid_ConcernVsConfident=="Confident about Vaccine",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, \nand Unfavorable Poll Result (COVID-19 Vaccine) Among Polls showing \nMajority Confidence about Vax Safety (Plausible Poll)",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.85)



#ai - BUT NO NEED TO TEST THIS FOR AI POLLS, SINCE BOTH CAN BE PLAUSIBLE, IT IS NOT LIKE COVID SECOND ORDER MISINFORMATION SITUATION ABOUT RISK PERCEPTIONS REPORTING IN POLL
table(d$manips_W2_AIregulation_SupportVsOppose)
r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute, 
        data=d[d$manips_W2_AIregulation_SupportVsOppose=="Oppose AI-Regulation",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (AI) \nAmong Polls showing Majority Oppose AI regulation",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(-.2,1)


r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute, 
        data=d[d$manips_W2_AIregulation_SupportVsOppose=="Support AI-Regulation",])
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute",
                                        "manips_W2_lowVshighQuality", "manips_w1ff"))
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute", "manips_W2_lowVshighQuality", "manips_w1ff"),
           title = "Perceived Credibility of Polls by Methodological Quality,Interventions, and \nUnfavorable Poll Result (AI) \nAmong Polls showing Majority Support AI regulation",
           axis.title = c("Unfavorable Poll Result","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(-.2,1)















################# ################ ################ ################ ################  producing the results table for credibility findings:

# report baselines and H1 (control) in paper, but not put in table to simplify

r1 = lm(pollcred_DV_4~manips_W2_lowVshighQuality, data=d)
summary(r1)
r2 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r2)
r3 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1, data=d) 
summary(r3)
r4 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*esl_total01, data=d) 
summary(r4)
r5 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1, data=d) 
summary(r5)
r6 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*educat01, data=d) 
summary(r6)
r7 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute, data=d)
summary(r7)
r8 = lm(pollcred_DV_4~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute, data=d)
summary(r8)

stargazer(r1, r2, r3, r4, r5, r6, r7, r8, type = "text", out = "Models.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))






















################ ################# ################ ################ ################  PERCEPTIONS AND INTENTIONS DVS...
# PRIORITIZE DIFFERENCE SCORES, CROSS-SECTINOAL ONES CAN GO TO APPENDIX....
# vax and ai dv
#crossect
d$W2_posttest_INDEX_vax_risk1_W2
d$W2_posttest_INDEX_vaxPO_risk1_W2
d$W2_post_VaxPerceptPOpercent_01
d$W2_post_VaxIntention_01
d$W2_post_Vax_Positivity_01
d$W2_posttest_INDEX_AI_risk1_W2
d$W2_posttest_INDEX_aiPO_risk1_W2
d$W2_post_aiPerceptPOpercent_01
d$W2_post_AI_PolicyView_01
d$W2_post_ai_Positivity_01

#diff scores
d$DIFFw2w1_INDEX_vax_risk1
d$DIFFw2w1_INDEX_vaxPO_risk1
d$DIFFw2w1_VaxPerceptPOpercent
d$DIFFw2w1_VaxIntention
d$DIFFw2w1_Vax_Positivity
d$DIFFw2w1_INDEX_AI_risk1
d$DIFFw2w1_INDEX_aiPO_risk1
d$DIFFw2w1_aiPerceptPOpercent_01
d$DIFFw2w1_AI_PolicyView_01
d$DIFFw2w1_ai_Positivity_01









#### DIFFERENCE SCORES - MORE ROBUST AND CONVERVATIVE
# for risk and PO perception outcomes, you have to control for directionality 
d$manips_W2_covid_ConcernVsConfident
d$manips_W2_AIregulation_SupportVsOppose

########## VACCINE RESULTS - 5 OUTCOMES MAIN TESTS (DO NOT INCLUDE INDIVIDUAL DIFFERENCE MODERATOTS YET)

##### 1) DIFFw2w1_INDEX_vax_risk1
#quality
r1 = aov(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

##### 2) DIFFw2w1_INDEX_vaxPO_risk1
#quality
r1 = aov(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Public Opinion Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Public Opinion Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 3) DIFFw2w1_VaxPerceptPOpercent
#quality
r1 = aov(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Public Opinion %-Perceptions (W2-W1) by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Public Opinion %-Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 
# violin version:

# remove NAs to be able to graph, select relevant data only:
dVax<-d[d$manips_W2_covidVsAI=="C-19 Vaccine Concern",]
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=dVax) 
summary(r1)
ggplot(dVax, aes(x=manips_w1ff,y=DIFFw2w1_VaxPerceptPOpercent, fill=manips_W2_covid_ConcernVsConfident)) + geom_violin(trim = TRUE) + 
  facet_grid(as.factor(dVax$manips_W2_lowVshighQuality)) +
  geom_boxplot(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("lightblue", "darkgray"),
                                                                                            labels=c('Low methods quality', 
                                                                                                     'High methods quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methods Quality and Trainings", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 








##### 4) DIFFw2w1_VaxIntention
#quality
r1 = aov(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in COVID-19 Vaccination Intentions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Intentions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 5) DIFFw2w1_Vax_Positivity
#quality
r1 = aov(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = aov(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in COVID-19 Vaccine Positivity (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Positivity (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 




########## ARTIFICIAL INTELLIGENCE RESULTS - 5 OUTCOMES MAIN TESTS (DO NOT INCLUDE INDIVIDUAL DIFFERENCE MODERATOTS YET)


##### 1) DIFFw2w1_INDEX_AI_risk1
#quality
r1 = aov(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Perceptions (W2-W1) by \nMethodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

##### 2) d$DIFFw2w1_INDEX_aiPO_risk1
#quality
r1 = aov(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Public Opinion Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Public Opinion Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


##### 3) d$DIFFw2w1_aiPerceptPOpercent_01
#quality
r1 = aov(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Risk Public Opinion %-Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Risk Public Opinion %-Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 



##### 4) d$DIFFw2w1_AI_PolicyView_01
#quality
r1 = aov(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Regulation Policy Support (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Regulation Policy Support (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 



##### 5) d$DIFFw2w1_ai_Positivity_01
#quality
r1 = aov(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = aov(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "Change in AI Positivity (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in AI Positivity (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 


















################## ################ ################ ################ ################  moderators for non-credibility diff-score outcomes

## d$DIFFw2w1_INDEX_vax_risk1 by all moderators:
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_vax_risk1~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)

# d$DIFFw2w1_INDEX_vaxPO_risk1 by all moderators
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)

# d$DIFFw2w1_VaxPerceptPOpercent  by all moderators:
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1) # SIGNIFICANT 
plot_model(r1, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality","manips_w1ff"))
r1 = lm(DIFFw2w1_VaxPerceptPOpercent~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)

# d$DIFFw2w1_VaxIntention  by all moderators:
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_VaxIntention~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)

# d$DIFFw2w1_Vax_Positivity  by all moderators:
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1) ### SIGNIFICANT
plot_model(r1, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality","manips_w1ff"))
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_Vax_Positivity~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_covid_ConcernVsConfident, data=d) 
summary(r1)


# d$DIFFw2w1_INDEX_AI_risk1 by all moderators:
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1)
plot_model(r1, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality","manips_w1ff"))
# WOW, un-treated/control group who has high subjective numeracy were moved by high-quality polls! their AI risk perception increased... but not a big deal
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1) ### SIGNIFICANT
plot_model(r1, type = "pred", terms = c("index_NewsLitBehave_W1","manips_W2_lowVshighQuality","manips_w1ff"))
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_AI_risk1~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)

# d$DIFFw2w1_INDEX_aiPO_risk1  by all moderators:
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1) #### SIGNIFICANT
plot_model(r1, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality","manips_w1ff"))
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1)
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)

# d$DIFFw2w1_aiPerceptPOpercent_01  by all moderators:
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1)
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1)
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)

# d$DIFFw2w1_AI_PolicyView_01  by all moderators:
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1)
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1)
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_AI_PolicyView_01~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)

# d$DIFFw2w1_ai_Positivity_01  by all moderators:
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*subjnum_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1)
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*esl_total01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1) ## SIGNIFICANT
plot_model(r1, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality","manips_w1ff"))
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*index_NewsLitBehave_W1+manips_W2_AIregulation_SupportVsOppose, data=d) # SIGNIFICANT
summary(r1)
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*educat01+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)
r1 = lm(DIFFw2w1_ai_Positivity_01~manips_W2_lowVshighQuality*manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_AIregulation_SupportVsOppose, data=d) 
summary(r1)














################## ################ ################  pre-registered as exploratory just like education moderation: GENERAL VIEWS OF POLLS AS AN OUTCOME VARIABLE (DIFF SCORE)

#GENERAL VIEWS OF POLLS AS AN OUTCOME VARIABLE (DIFF SCORE)

### GOOD, "INTERVENTIONS" DID NOT SHIFT ATTITUDES TOWARDS POLLS IN GENERAL, AS IT WAS NOT THE INTENTION
### ONE WORRY WAS THAT INTERVENTIONS MIGHT INCREASE GENERAL SKEPTICISM, BUT THAT WAS NOT OBSERVED

# 6 variables:

d$index3item_generalpollcredibility_W2_manipcheck # null
d$Diff_W2minusW1pretest_credible_pollsInGeneral #null
d$index_pollgeneralConcern3items_W2 # null
d$Diff_W2minusW1pretest_concern1_pollsInGeneral # null
d$index_poll_efficacy_W2 # null
d$Diff_W2minusW1pretest_efficacy_pollsInGeneral #NULL


r1 = aov(Diff_W2minusW1pretest_efficacy_pollsInGeneral~manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r1)
TukeyHSD(r1)
r1 = lm(Diff_W2minusW1pretest_efficacy_pollsInGeneral~manips_W2_lowVshighQuality*manips_w1ff, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality"),
           title = "Perceived Credibility of Polls by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 
















########################## ################ ################ ################  CROSSSECTIONAL SCORES FOR NON-CREDIBILTIY OUTCOMES

# CROSSECTIONALS
#crossect
d$W2_posttest_INDEX_vax_risk1_W2 # null controlling for pretest 
d$W2_posttest_INDEX_vaxPO_risk1_W2 # null controlling for pretest 
d$W2_post_VaxPerceptPOpercent_01 # SIGNIFICANT, same result as expected with difference score approach above
d$W2_post_VaxIntention_01 # null controlling for pretest 
d$W2_post_Vax_Positivity_01 # null controlling for pretest 

d$W2_posttest_INDEX_AI_risk1_W2  # SIGNIFICANT some expected effect high quality polls matter depending on poll directionality among inoculation group... 
d$W2_posttest_INDEX_aiPO_risk1_W2 # null controlling for pretest 
d$W2_post_aiPerceptPOpercent_01 # null controlling for pretest 
d$W2_post_AI_PolicyView_01 # null controlling for pretest 
d$W2_post_ai_Positivity_01

#PRE-TEST CONTROLS
d$pretest_INDEX_vax_risk1_W1 
d$pretest_INDEX_vaxPO_risk1_W1 
d$pre_VaxPerceptPOpercent_01     
d$pre_VaxIntention_01
d$pre_Vax_Positivity_01 

d$pretest_INDEX_AI_risk1_W1
d$pretest_INDEX_aiPO_risk1_W1
d$pre_aiPerceptPOpercent_01 
d$pre_AI_PolicyView_01 
d$pre_ai_Positivity_01

# vax
r1 = aov(W2_post_VaxPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_W2_covid_ConcernVsConfident+pre_VaxPerceptPOpercent_01, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_covid_ConcernVsConfident"))
#quality X intervention
r1 = lm(W2_post_VaxPerceptPOpercent_01~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_covid_ConcernVsConfident+pre_VaxPerceptPOpercent_01, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_covid_ConcernVsConfident"),
           title = "Change in Vaccine Risk Perceptions (W2-W1) \nby Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 

# ai
r1 = aov(W2_posttest_INDEX_AI_risk1_W2~manips_W2_lowVshighQuality*manips_W2_AIregulation_SupportVsOppose+pretest_INDEX_AI_risk1_W1, data=d)
summary(r1)
TukeyHSD(r1)
plot_model(r1, type = "pred", terms = c("manips_W2_lowVshighQuality", "manips_W2_AIregulation_SupportVsOppose"))
#quality X intervention
r1 = lm(W2_posttest_INDEX_AI_risk1_W2~manips_W2_lowVshighQuality*manips_w1ff*manips_W2_AIregulation_SupportVsOppose+pretest_INDEX_AI_risk1_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality","manips_W2_AIregulation_SupportVsOppose"),
           title = "AI Risk Perceptions (W2) by Methodological Quality and Interventions while Controlling for W1 Pretest AI Risk Perceptions",
           axis.title = c("Interventions (W1)","Change in Vaccine Risk Perceptions (W2-W1)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("lightblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) 



















############# ############# ############# ############# ############# ############# ############# 

############# ############# ############# ############# ############# ############# ############# 

############# ############# ############# ############# ############# ############# ############# 

############# ############# ############# ############# ############# ############# ############# 

############# ############# ############# ############# ############# ############# ############# 

############# ############# ############# ############# ############# ############# ############# 


############# POQ REVISION EDITS. FEBRUARY 2025


# combine motivated rasoning tests by pooling the issues - use this approach in 8variable solution model below too
# combine these two
table(d$RseenAttitudeInconsistentPO_vaxrisk_absolute)
table(d$RseenAttitudeInconsistentPO_AIrisk_absolute)
# vax bias
d$bias_vax<-d$RseenAttitudeInconsistentPO_vaxrisk_absolute
# AI bias
d$bias_AI<-d$RseenAttitudeInconsistentPO_AIrisk_absolute
d$bias_vax[is.na(d$bias_vax)] <- 0
d$bias_AI[is.na(d$bias_AI)] <- 0
#pooled
d$bias_POOLED <- d$bias_vax + d$bias_AI
table(d$bias_POOLED)

r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("bias_POOLED","manips_W2_lowVshighQuality"))

r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*bias_POOLED*manips_w1ff
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("bias_POOLED","manips_W2_lowVshighQuality","manips_w1ff"))







### Original first submission main analysis starts on line 2278

# main old model
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)


# subset by quality
table(d$manips_W2_lowVshighQuality)

r1a = lm(pollcred_DV_5~manips_w1ff
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="Low Quality",]) 
summary(r1a)

d$interactioncontrasts <- with(d, interaction(manips_w1ff, sep = "x"))
head(d$interactioncontrasts)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m1 = lm(pollcred_DV_5~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="Low Quality",]) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
cld(r1b)
# INOC VS active - gives same results as multicomp command above, but significance is different it is not tukey adjusted..another adjustment:
K <- matrix(c(0, 0, 1, -1, 0, 0, 0, 0, 0), 1) #INOC
K
t <- glht(r1a, linfct = K)
summary(t)


r1b = lm(pollcred_DV_5~manips_w1ff
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="High Quality",]) 
summary(r1b)
stargazer(r1a, r1b, type = "text", out = "SubsetbyQuality.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 

d$interactioncontrasts <- with(d, interaction(manips_w1ff, sep = "x"))
head(d$interactioncontrasts)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m1 = lm(pollcred_DV_5~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="High Quality",]) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
cld(r1b)

# subset by W1 conditions

table(d$manips_w1ff)

r1a = lm(pollcred_DV_5~manips_W2_lowVshighQuality
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Control (W1)",]) 
summary(r1a)
plot_model(r1a, type = "pred", terms = c("manips_W2_lowVshighQuality"))

r1b = lm(pollcred_DV_5~manips_W2_lowVshighQuality
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int1: Passive Literacy (W1)",]) 
summary(r1b)
plot_model(r1b, type = "pred", terms = c("manips_W2_lowVshighQuality"))

r1c = lm(pollcred_DV_5~manips_W2_lowVshighQuality
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int2: Active Literacy (W1)",]) 
summary(r1c)
plot_model(r1c, type = "pred", terms = c("manips_W2_lowVshighQuality"))

r1d = lm(pollcred_DV_5~manips_W2_lowVshighQuality
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int3: Inoculation (W1)",]) 
summary(r1d)
plot_model(r1d, type = "pred", terms = c("manips_W2_lowVshighQuality"))

stargazer(r1a, r1b, r1c, r1d, type = "text", out = "SubsetbyW1arms.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 




# Bootstrap 95% CI for regression coefficients
library(boot)
set.seed(123)

#quantile(coef(results_passive)$manips_W2_lowVshighQuality -coef(results_control)$manips_W2_lowVshighQuality, type="bca", index=2) 

dx1<-d[d$manips_w1ff=="Control (W1)",]
dx2<-d[d$manips_w1ff=="Int1: Passive Literacy (W1)",]
dx3<-d[d$manips_w1ff=="Int2: Active Literacy (W1)",]
dx4<-d[d$manips_w1ff=="Int3: Inoculation (W1)",]

control_bootstp <-sapply(1:5000, function(x) coef(lm(pollcred_DV_5~manips_W2_lowVshighQuality + 
                                                       Age_Years + Chinese01 + Indian + 
                                                       pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, 
                                                     data=dx1[sample(1:nrow(dx1), nrow(dx1), replace=TRUE),])))


passive_bootstp <-sapply(1:5000, function(x) coef(lm(pollcred_DV_5~manips_W2_lowVshighQuality + 
                                                       Age_Years + Chinese01 + Indian + 
                                                       pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, 
                                                     data=dx2[sample(1:nrow(dx2), nrow(dx2), replace=TRUE),])))

active_bootstp <-sapply(1:5000, function(x) coef(lm(pollcred_DV_5~manips_W2_lowVshighQuality + 
                                                       Age_Years + Chinese01 + Indian + 
                                                       pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, 
                                                     data=dx3[sample(1:nrow(dx3), nrow(dx3), replace=TRUE),])))

inoc_bootstp <-sapply(1:5000, function(x) coef(lm(pollcred_DV_5~manips_W2_lowVshighQuality + 
                                                      Age_Years + Chinese01 + Indian + 
                                                      pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, 
                                                    data=dx4[sample(1:nrow(dx4), nrow(dx4), replace=TRUE),])))


# individual bootstrap CIs for each 4 subsets: (put these into table)
quantile(control_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))
quantile(passive_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))
quantile(active_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))
quantile(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))

# bootsrap CI for pairwise differences among 4 subsets: (put these into text or just p values below maybe)
quantile(passive_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))
quantile(active_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))
quantile(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))
quantile(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           passive_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))
quantile(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           active_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))
quantile(active_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           passive_bootstp["manips_W2_lowVshighQualityHigh Quality",], c(.025, .975))

# p values for pairwise differences among 4 subsets: (put these into text)
# this is p value for single CI (not pairwise diff)
p0<- sum(control_bootstp["manips_W2_lowVshighQualityHigh Quality",] > 0) / 
  length(control_bootstp["manips_W2_lowVshighQualityHigh Quality",])
p0 # 83% greater than 0 -  2tailed -- p times X2= .34 approx.
# take the difference...for above so i can provide a p value for difference as well....
# then this is for pairwise differece:
# take the smaller of two p values and then multiply
p1<- sum(passive_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",] > 0) / 
  length(passive_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",])
p1

p2<- sum(active_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",] > 0) / 
  length(active_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",])
p2

p3<- sum(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",] > 0) / 
  length(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           control_bootstp["manips_W2_lowVshighQualityHigh Quality",])
p3

p4<- sum(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           passive_bootstp["manips_W2_lowVshighQualityHigh Quality",] > 0) / 
  length(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           passive_bootstp["manips_W2_lowVshighQualityHigh Quality",])
p4

p5<- sum(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           active_bootstp["manips_W2_lowVshighQualityHigh Quality",] > 0) / 
  length(inoc_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           active_bootstp["manips_W2_lowVshighQualityHigh Quality",])
p5

p6<- sum(active_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           passive_bootstp["manips_W2_lowVshighQualityHigh Quality",] > 0) / 
  length(active_bootstp["manips_W2_lowVshighQualityHigh Quality",] - 
           passive_bootstp["manips_W2_lowVshighQualityHigh Quality",])
p6




#  mods
educat01
esl_total01
subjnum_W1
RseenAttitudeInconsistentPO_vaxrisk_absolute
RseenAttitudeInconsistentPO_AIrisk_absolute
bias_POOLED

# 1) as subsetted by quality
# subset by quality - EDUCATION
r1a1 = lm(pollcred_DV_5~manips_w1ff*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="Low Quality",]) 
summary(r1a1)
plot_model(r1a1, type = "pred", terms = c("educat01","manips_w1ff"))
plot_model(r1a1, type = "pred", terms = c("educat01","manips_w1ff"),
           title = "Figure 1: Perceived Credibility of Polls by Interventions and \nIndividuals' Education Levels (among Low quality polls)",
           axis.title = c("Education Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "W1 Condition", dodge = .3,
           colors=c("darkgray", "black", "lightblue", "brown"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.2,.65)
r1a2 = lm(pollcred_DV_5~manips_w1ff*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="High Quality",]) 
summary(r1a2)
plot_model(r1a2, type = "pred", terms = c("educat01","manips_w1ff"))


# subsetted by quality - SCIENCE LIT
r1b1 = lm(pollcred_DV_5~manips_w1ff*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="Low Quality",]) 
summary(r1b1)
plot_model(r1b1, type = "pred", terms = c("esl_total01","manips_w1ff"))
r1b2 = lm(pollcred_DV_5~manips_w1ff*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="High Quality",]) 
summary(r1b2)
plot_model(r1b2, type = "pred", terms = c("esl_total01","manips_w1ff"))
plot_model(r1b2, type = "pred", terms = c("esl_total01","manips_w1ff"),
           title = "Figure 2: Perceived Credibility of Polls by Interventions and \nIndividuals' Science Literacy Levels (among High quality polls)",
           axis.title = c("Science Literacy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "W1 Condition", dodge = .3,
           colors=c("darkgray", "black", "lightblue", "brown"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.2,.65)

# subset by quality - SUB NUM
r1c1 = lm(pollcred_DV_5~manips_w1ff*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="Low Quality",]) 
summary(r1c1)
plot_model(r1c1, type = "pred", terms = c("subjnum_W1","manips_w1ff"))
r1c2 = lm(pollcred_DV_5~manips_w1ff*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_W2_lowVshighQuality=="High Quality",]) 
summary(r1c2)
plot_model(r1c2, type = "pred", terms = c("subjnum_W1","manips_w1ff"))



stargazer(r1a1, r1a2, r1b1, r1b2, r1c1, r1c2, type = "text", out = "Subsetbyquality_moderatorsfirst3.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 



# subset by quality - bias for vax
r1d1 = lm(pollcred_DV_5~manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_lowVshighQuality=="Low Quality",]) 
summary(r1d1)
plot_model(r1d1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_w1ff"))
r1d2 = lm(pollcred_DV_5~manips_w1ff*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_lowVshighQuality=="High Quality",]) 
summary(r1d2)
plot_model(r1d2, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_w1ff"))


# subset by quality - bias for ai
r1e1 = lm(pollcred_DV_5~manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_lowVshighQuality=="Low Quality",]) 
summary(r1e1)
plot_model(r1e1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_w1ff"))

r1e2 = lm(pollcred_DV_5~manips_w1ff*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_lowVshighQuality=="High Quality",]) 
summary(r1e2)
plot_model(r1e2, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_w1ff"))
plot_model(r1e2, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_w1ff"),
           title = "Figure 3: Perceived Credibility of Polls by Interventions and \nUnfavorable (AI) Polls (among High quality polls)",
           axis.title = c("Unfavorable (AI) Polls","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "W1 Condition", dodge = .3,
           colors=c("darkgray", "black", "lightblue", "brown"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.2,.7)

# subset by quality - COMBINED bias 
r1f1 = lm(pollcred_DV_5~manips_w1ff*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_lowVshighQuality=="Low Quality",]) 
summary(r1f1)
plot_model(r1f1, type = "pred", terms = c("bias_POOLED","manips_w1ff"))

r1f2 = lm(pollcred_DV_5~manips_w1ff*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_W2_lowVshighQuality=="High Quality",]) 
summary(r1f2)
plot_model(r1f2, type = "pred", terms = c("bias_POOLED","manips_w1ff"))


stargazer(r1d1, r1d2, r1e1, r1e2, r1f1, r1f2, type = "text", out = "Subsetbyquality_moderatorslast3.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 








# 1) as subsetted by W1 conditions
# edu
r1a = lm(pollcred_DV_5~manips_W2_lowVshighQuality*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Control (W1)",]) 
summary(r1a)
plot_model(r1a, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality"))

r1b = lm(pollcred_DV_5~manips_W2_lowVshighQuality*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int1: Passive Literacy (W1)",]) 
summary(r1b)
plot_model(r1b, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality"))
plot_model(r1b, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality"),
           title = "Figure 4: Perceived Credibility of Polls by Poll Quality and \nIndividuals' Education Levels (among Passive Literacy participants)",
           axis.title = c("Education Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.2,.7)




r1c = lm(pollcred_DV_5~manips_W2_lowVshighQuality*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int2: Active Literacy (W1)",]) 
summary(r1c)
plot_model(r1c, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality"))
plot_model(r1c, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality"),
           title = "Figure 5: Perceived Credibility of Polls by Poll Quality and \nIndividuals' Education Levels (among Active Literacy participants)",
           axis.title = c("Education Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.2,.7)

r1d = lm(pollcred_DV_5~manips_W2_lowVshighQuality*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int3: Inoculation (W1)",]) 
summary(r1d)
plot_model(r1d, type = "pred", terms = c("educat01","manips_W2_lowVshighQuality"))

stargazer(r1a, r1b, r1c, r1d, type = "text", out = "SubsetbyW1arms_moderatorsEDU.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 



# sci lit
r1a = lm(pollcred_DV_5~manips_W2_lowVshighQuality*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Control (W1)",]) 
summary(r1a)
plot_model(r1a, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality"))
plot_model(r1a, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality"),
           title = "Figure 6: Perceived Credibility of Polls by Poll Quality and \nIndividuals' Science Literacy Levels (among Control participants)",
           axis.title = c("Science Literacy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.15,.7)

r1b = lm(pollcred_DV_5~manips_W2_lowVshighQuality*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int1: Passive Literacy (W1)",]) 
summary(r1b)
plot_model(r1b, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality"))

r1c = lm(pollcred_DV_5~manips_W2_lowVshighQuality*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int2: Active Literacy (W1)",]) 
summary(r1c)
plot_model(r1c, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality"))

r1d = lm(pollcred_DV_5~manips_W2_lowVshighQuality*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int3: Inoculation (W1)",]) 
summary(r1d)
plot_model(r1d, type = "pred", terms = c("esl_total01","manips_W2_lowVshighQuality"))

stargazer(r1a, r1b, r1c, r1d, type = "text", out = "SubsetbyW1arms_moderatorsSCILIT.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 

# subj num
r1a = lm(pollcred_DV_5~manips_W2_lowVshighQuality*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Control (W1)",]) 
summary(r1a)
plot_model(r1a, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality"))

r1b = lm(pollcred_DV_5~manips_W2_lowVshighQuality*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int1: Passive Literacy (W1)",]) 
summary(r1b)
plot_model(r1b, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality"))

r1c = lm(pollcred_DV_5~manips_W2_lowVshighQuality*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int2: Active Literacy (W1)",]) 
summary(r1c)
plot_model(r1c, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality"))
plot_model(r1c, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality"),
           title = "Figure 7: Perceived Credibility of Polls by Poll Quality and \nIndividuals' Subjective Numeracy Levels (among Active Literacy \nparticipants)",
           axis.title = c("Subjective Numeracy","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.2,.7)


r1d = lm(pollcred_DV_5~manips_W2_lowVshighQuality*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d[d$manips_w1ff=="Int3: Inoculation (W1)",]) 
summary(r1d)
plot_model(r1d, type = "pred", terms = c("subjnum_W1","manips_W2_lowVshighQuality"))

stargazer(r1a, r1b, r1c, r1d, type = "text", out = "SubsetbyW1arms_moderatorsSUBNUM.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 

# bias vax
r1a = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Control (W1)",]) 
summary(r1a)
plot_model(r1a, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_W2_lowVshighQuality"))

r1b = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int1: Passive Literacy (W1)",]) 
summary(r1b)
plot_model(r1b, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_W2_lowVshighQuality"))

r1c = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int2: Active Literacy (W1)",]) 
summary(r1c)
plot_model(r1c, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_W2_lowVshighQuality"))

r1d = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int3: Inoculation (W1)",]) 
summary(r1d)
plot_model(r1d, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","manips_W2_lowVshighQuality"))

stargazer(r1a, r1b, r1c, r1d, type = "text", out = "SubsetbyW1arms_moderatorsBIASvax.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 


# bias AI
r1a = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Control (W1)",]) 
summary(r1a)
plot_model(r1a, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_W2_lowVshighQuality"))

r1b = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int1: Passive Literacy (W1)",]) 
summary(r1b)
plot_model(r1b, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_W2_lowVshighQuality"))

r1c = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int2: Active Literacy (W1)",]) 
summary(r1c)
plot_model(r1c, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_W2_lowVshighQuality"))

r1d = lm(pollcred_DV_5~manips_W2_lowVshighQuality*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int3: Inoculation (W1)",]) 
summary(r1d)
plot_model(r1d, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","manips_W2_lowVshighQuality"))


stargazer(r1a, r1b, r1c, r1d, type = "text", out = "SubsetbyW1arms_moderatorsBIASai.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 


# combined bias
r1a = lm(pollcred_DV_5~manips_W2_lowVshighQuality*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Control (W1)",]) 
summary(r1a)
plot_model(r1a, type = "pred", terms = c("bias_POOLED","manips_W2_lowVshighQuality"))

r1b = lm(pollcred_DV_5~manips_W2_lowVshighQuality*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int1: Passive Literacy (W1)",]) 
summary(r1b)
plot_model(r1b, type = "pred", terms = c("bias_POOLED","manips_W2_lowVshighQuality"))

r1c = lm(pollcred_DV_5~manips_W2_lowVshighQuality*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int2: Active Literacy (W1)",]) 
summary(r1c)
plot_model(r1c, type = "pred", terms = c("bias_POOLED","manips_W2_lowVshighQuality"))

r1d = lm(pollcred_DV_5~manips_W2_lowVshighQuality*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d[d$manips_w1ff=="Int3: Inoculation (W1)",]) 
summary(r1d)
plot_model(r1d, type = "pred", terms = c("bias_POOLED","manips_W2_lowVshighQuality"))
plot_model(r1d, type = "pred", terms = c("bias_POOLED","manips_W2_lowVshighQuality"),
           title = "Figure 8: Perceived Credibility of Polls by Poll Quality and \nUnfavorable (Vaccine and AI pooled) Polls (among Inoculation \nparticipants) (interaction at p=.051 only)",
           axis.title = c("Unfavorable (Vaccine and AI pooled) Polls","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.2,.7)


stargazer(r1a, r1b, r1c, r1d, type = "text", out = "SubsetbyW1arms_moderatorsBIASpooled.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 















# 8 VARIABLE CODING ALTERNATIVE

# lets create a 8-way variable using W1 and W2 major manips to bypass 2-way interaction of those 2 variables

# why is this good - we avoid interaction and in a single model! instead of what R3 proposed as unneat multiple separate models...


# main old model
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)


table(d$manips_w1ff)
table(d$manips_w1)

table(d$manips_W2_lowVshighQuality)
d$manips_W2_lowVshighQuality_numeric<-d$manips_W2_lowVshighQuality
d$manips_W2_lowVshighQuality_numeric<-as.numeric(d$manips_W2_lowVshighQuality_numeric)
is.numeric(d$manips_W2_lowVshighQuality_numeric)
table(d$manips_W2_lowVshighQuality_numeric)
d$manips_W2_lowVshighQuality_numeric[d$manips_W2_lowVshighQuality_numeric==1] <- 10
d$manips_W2_lowVshighQuality_numeric[d$manips_W2_lowVshighQuality_numeric==2] <- 100
table(d$manips_W2_lowVshighQuality_numeric)

d$EightMajorConditons<- d$manips_w1 * d$manips_W2_lowVshighQuality_numeric
table(d$EightMajorConditons)

d$EightMajorConditons[d$EightMajorConditons==10] <- "ControlSeenLowQuality"
d$EightMajorConditons[d$EightMajorConditons==20] <- "PassiveSeenLowQuality"
d$EightMajorConditons[d$EightMajorConditons==30] <- "ActiveSeenLowQuality"
d$EightMajorConditons[d$EightMajorConditons==40] <- "InoculationSeenLowQuality"
d$EightMajorConditons[d$EightMajorConditons==100] <- "ControlSeenHighQuality"
d$EightMajorConditons[d$EightMajorConditons==200] <- "PassiveSeenHighQuality"
d$EightMajorConditons[d$EightMajorConditons==300] <- "ActiveSeenHighQuality"
d$EightMajorConditons[d$EightMajorConditons==400] <- "InoculationSeenHighQuality"
table(d$EightMajorConditons)

d$EightMajorConditons <- factor(d$EightMajorConditons, levels = c("ControlSeenLowQuality",
                                                                  "PassiveSeenLowQuality",
                                                                  "ActiveSeenLowQuality",
                                                                  "InoculationSeenLowQuality",
                                                                  "ControlSeenHighQuality",
                                                                  "PassiveSeenHighQuality",
                                                                  "ActiveSeenHighQuality",
                                                                  "InoculationSeenHighQuality"))
table(d$EightMajorConditons)
is.factor(d$EightMajorConditons)

d$EMC<-d$EightMajorConditons




# alternative ordering of conditoions:
d$EightMajorConditons2 <- factor(d$EightMajorConditons, levels = c("ControlSeenLowQuality",
                                                                   "ControlSeenHighQuality",
                                                                  "PassiveSeenLowQuality",
                                                                  "PassiveSeenHighQuality",
                                                                  "ActiveSeenLowQuality",
                                                                  "ActiveSeenHighQuality",
                                                                  "InoculationSeenLowQuality",
                                                                  "InoculationSeenHighQuality"))
table(d$EightMajorConditons2)
is.factor(d$EightMajorConditons2)

d$EMC2<-d$EightMajorConditons2



# baseline model for H1 - without accounting for experimental groups, poll quality as sole predictor aside from controls

r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)


# main model: - we get the same results as original submission, of course

r1 = lm(pollcred_DV_5~EMC
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("EMC"))


r1 = lm(pollcred_DV_5~EMC2
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("EMC2"))

stargazer(r1, type = "text", out = "Main_8way.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 



# good but also need pairwise tests multicomp..
#----THIS IS EASY

# first test to see IF I CAN TEST INTERVENTIONS AS R3 ASKED
r1 = lm(pollcred_DV_5~EMC2
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("EMC2"))

# LETS COMPARE inoculuation low vs high quality
r1$coef[7]
r1$coef[8]
r1$coef[7] - r1$coef[8]
# and this contrast coding approach gives us significance test too:
K <- matrix(c(0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0), 1)
t <- glht(r1, linfct = K)
summary(t)

# lets do for passive low vs high. 
r1$coef[3]
r1$coef[4]
K <- matrix(c(0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1)
t <- glht(r1, linfct = K)
summary(t) # -- THIS TOO SIGNIFICANT BUT THESE ARE T-TESTS, MY TUKEYS ARE MORE CONSERVATIVE..


# lets do for active low vs high. 
r1$coef[5]
r1$coef[6]
K <- matrix(c(0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0), 1)
t <- glht(r1, linfct = K)
summary(t) # -- THIS TOO SIGNIFICANT BUT THESE ARE T-TESTS, MY TUKEYS ARE MORE CONSERVATIVE..


# lets compare W1 MANIPS across low vs high collectively 
# INOC VS. ACTIVE
K1 <- matrix(c(0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0), 1) #INOC
K2 <- matrix(c(0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0), 1) #ACTIVE
K <- K1 - K2
K
t <- glht(r1, linfct = K)
summary(t)

# INOC VS PASSIVE
K1 <- matrix(c(0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0), 1) #INOC
K2 <- matrix(c(0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1) #PASSIVE
K <- K1 - K2
K
t <- glht(r1, linfct = K)
summary(t)

# PASS VS ACTIVE
K1 <- matrix(c(0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1) #PASSIVE
K2 <- matrix(c(0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0), 1) #ACTIVE
K <- K1 - K2
K
t <- glht(r1, linfct = K)
summary(t)


# INOC interact:
K1 <- matrix(c(0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0), 1) 
K2 <- matrix(c(0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0), 1) 
K3 <- K1 - K2
K3
t <- glht(r1, linfct = K3)
summary(t) # this value match the interaction effect in original submission models
# active interact:
K1 <- matrix(c(0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0), 1) 
K2 <- matrix(c(0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0), 1) 
K3 <- K1 - K2
K3
t <- glht(r1, linfct = K3)
summary(t) # this value match the interaction effect in original submission models
# passive interact:
K1 <- matrix(c(0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1) 
K2 <- matrix(c(0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1) 
K3 <- K1 - K2
K3
t <- glht(r1, linfct = K3)
summary(t) # this value match the interaction effect in original submission models










### EXACT SAME RESULTSTO MY DIRECT INTERACTION COMPARISONS ABOVE AROUND LINE 2830 FEBRUARY

###  SO WE CAN

# 1) USE THIS 8-WAY SIMPLER MODEL WITHOUT INTERACTION FOR MAIN EFFECTS
# 2) REPORT ALL PAIRWISE AND INTERVENTION COMPARISONS 
# 3) USE JUST 2-WAY INTERACTIONS FOR INDIVIDUAL DIFFERENCES 
# 4) DROP PUBLIC OPINION PERCEPTIONS OUTCOMES to appendix
# 5) POOLED ANALYSIS FOR MOTIVATED REASONING - COMBINE ISSUES


### We can keep these figurs because it is the same:

# print model 0 for table 2
r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
stargazer(r1, type = "text", out = "Model0forTable2.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 





r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff+
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("manips_w1ff","manips_W2_lowVshighQuality"))

plot_model(r1, type = "pred", terms = c("manips_w1ff", "manips_W2_lowVshighQuality"),
           title = "Perceived Credibility of Polls by Methodological Quality and Interventions",
           axis.title = c("Interventions (W1)","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 2,
           legend.title = "Methodological Quality of Polls (W2)", dodge = .3,
           colors=c("blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "bottom", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0,.9) 

#  TIGER plot
ggplot(d, aes(x=manips_w1ff,y=pollcred_DV_5, fill=manips_W2_lowVshighQuality)) + geom_violin(trim = TRUE) + 
  geom_count(width=0.2, color="black",position = position_dodge(.9)) +  scale_fill_manual(values=c("blue", "darkgray"),
                                                                                          labels=c('Low Quality', 
                                                                                                   'High Quality'), name="") + 
  theme_classic() + theme(legend.position="bottom") + 
  labs(title="Perceived Credibility of Polls by Methodological Quality and Interventions", x="W1 Conditions", 
       y = "Perceived Credibility of Polls") + 
  #  scale_x_discrete(label = c("Control","Passive Literacy","Active Literacy", "Inoculation")) + 
  theme(text = element_text(size = 14)) 





# lets try pairwises for this 8-condition variable:
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
head(d$interactioncontrasts)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m1 = lm(pollcred_DV_5~interactioncontrasts
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
cld(r1b)
# another method, and gives same results as above lenghty, mnultistep code:
# but downside is that it does not show significance stars, 
lsmeans(r1, pairwise~EMC2, adjust="tukey")

# table creation for pairwise diffs - reference code / thanks to: https://gist.github.com/ajpelu/194e721077ec045a2b864088908e7aca
table_glht <- function(x) {
  pq <- summary(x)$test
  mtests <- cbind(pq$coefficients, pq$sigma, pq$tstat, pq$pvalues)
  error <- attr(pq$pvalues, "error")
  pname <- switch(x$alternativ, less = paste("Pr(<", ifelse(x$df ==0, "z", "t"), ")", sep = ""), 
                  greater = paste("Pr(>", ifelse(x$df == 0, "z", "t"), ")", sep = ""), two.sided = paste("Pr(>|",ifelse(x$df == 0, "z", "t"), "|)", sep = ""))
  colnames(mtests) <- c("Estimate", "Std. Error", ifelse(x$df ==0, "z value", "t value"), pname)
  return(mtests)
  
}

table_glht(r1b)

stargazer(table_glht(r1b), type = "text", out = "Main_8way_tukeys.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 










#  moderators
educat01
esl_total01
subjnum_W1
RseenAttitudeInconsistentPO_vaxrisk_absolute
RseenAttitudeInconsistentPO_AIrisk_absolute
table(d$bias_POOLED)


r1 = lm(pollcred_DV_5~EMC2*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("educat01","EMC2"))
plot_model(r1, type = "pred", terms = c("EMC2","educat01"))

r1 = lm(pollcred_DV_5~EMC2*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("esl_total01","EMC2"))
plot_model(r1, type = "pred", terms = c("EMC2","esl_total01"))

r1 = lm(pollcred_DV_5~EMC2*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("subjnum_W1","EMC2"))
plot_model(r1, type = "pred", terms = c("EMC2","subjnum_W1"))

r1 = lm(pollcred_DV_5~EMC2*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","EMC2"))
plot_model(r1, type = "pred", terms = c("EMC2","RseenAttitudeInconsistentPO_vaxrisk_absolute"))


r1 = lm(pollcred_DV_5~EMC2*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","EMC2"))
plot_model(r1, type = "pred", terms = c("EMC2","RseenAttitudeInconsistentPO_AIrisk_absolute"))


# also do combined pooled bias test:
table(d$bias_POOLED)

r1 = lm(pollcred_DV_5~EMC2*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1) 
plot_model(r1, type = "pred", terms = c("bias_POOLED","EMC2"))
plot_model(r1, type = "pred", terms = c("EMC2","bias_POOLED"))
# all insignificant interacts but these are against control, do pairwise:
d$interactioncontrasts <- with(d, interaction(EMC2, bias_POOLED, sep = "x"))
head(d$interactioncontrasts)
#All pairwise comparisons can then be calculated automatically by entering the interaction variable into the model as a single predictor.
m1 = lm(pollcred_DV_5~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
cld(r1b)
# another method, and gives same results as above lenghty, mnultistep code:
# but downside is that it does not show significance stars, 
# at least this gives me confidence (same results) that the warning message in above code can be ignored
lsmeans(r1, pairwise~EMC2, adjust="tukey")









# how about PO perception DVs

#crossect
d$W2_posttest_INDEX_vax_risk1_W2
d$W2_posttest_INDEX_vaxPO_risk1_W2
d$W2_post_VaxPerceptPOpercent_01
d$W2_post_VaxIntention_01
d$W2_post_Vax_Positivity_01
d$W2_posttest_INDEX_AI_risk1_W2
d$W2_posttest_INDEX_aiPO_risk1_W2
d$W2_post_aiPerceptPOpercent_01
d$W2_post_AI_PolicyView_01
d$W2_post_ai_Positivity_01

#diff scores
d$DIFFw2w1_INDEX_vax_risk1
d$DIFFw2w1_INDEX_vaxPO_risk1
d$DIFFw2w1_VaxPerceptPOpercent
d$DIFFw2w1_VaxIntention
d$DIFFw2w1_Vax_Positivity
d$DIFFw2w1_INDEX_AI_risk1
d$DIFFw2w1_INDEX_aiPO_risk1
d$DIFFw2w1_aiPerceptPOpercent_01
d$DIFFw2w1_AI_PolicyView_01
d$DIFFw2w1_ai_Positivity_01


r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~EMC2*manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, manips_W2_covid_ConcernVsConfident, sep = "x"))
m1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)

r1 = lm(DIFFw2w1_VaxPerceptPOpercent~EMC2*manips_W2_covid_ConcernVsConfident+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, manips_W2_covid_ConcernVsConfident, sep = "x"))
m1 = lm(DIFFw2w1_VaxPerceptPOpercent~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~EMC2*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, manips_W2_AIregulation_SupportVsOppose, sep = "x"))
m1 = lm(DIFFw2w1_INDEX_aiPO_risk1~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~EMC2*manips_W2_AIregulation_SupportVsOppose+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, manips_W2_AIregulation_SupportVsOppose, sep = "x"))
m1 = lm(DIFFw2w1_aiPerceptPOpercent_01~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


#or subset by poll directionality
table(d$manips_W2_covid_ConcernVsConfident)

r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~EMC2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=
          d[d$manips_W2_covid_ConcernVsConfident=="Concerned about Vaccine",]) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
m1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


r1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~EMC2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=
          d[d$manips_W2_covid_ConcernVsConfident=="Confident about Vaccine",]) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
m1 = lm(DIFFw2w1_INDEX_vaxPO_risk1~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


r1 = lm(DIFFw2w1_VaxPerceptPOpercent~EMC2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=
          d[d$manips_W2_covid_ConcernVsConfident=="Concerned about Vaccine",]) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
m1 = lm(DIFFw2w1_VaxPerceptPOpercent~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


r1 = lm(DIFFw2w1_VaxPerceptPOpercent~EMC2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=
          d[d$manips_W2_covid_ConcernVsConfident=="Confident about Vaccine",]) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
m1 = lm(DIFFw2w1_VaxPerceptPOpercent~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


table(d$manips_W2_AIregulation_SupportVsOppose)

r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~EMC2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=
          d[d$manips_W2_AIregulation_SupportVsOppose=="Oppose AI-Regulation",]) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
m1 = lm(DIFFw2w1_INDEX_aiPO_risk1~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


r1 = lm(DIFFw2w1_INDEX_aiPO_risk1~EMC2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=
          d[d$manips_W2_AIregulation_SupportVsOppose=="Support AI-Regulation",]) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
m1 = lm(DIFFw2w1_INDEX_aiPO_risk1~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)

r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~EMC2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=
          d[d$manips_W2_AIregulation_SupportVsOppose=="Oppose AI-Regulation",]) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
m1 = lm(DIFFw2w1_aiPerceptPOpercent_01~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)


r1 = lm(DIFFw2w1_aiPerceptPOpercent_01~EMC2+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=
          d[d$manips_W2_AIregulation_SupportVsOppose=="Support AI-Regulation",]) 
summary(r1)
d$interactioncontrasts <- with(d, interaction(EMC2, sep = "x"))
m1 = lm(DIFFw2w1_aiPerceptPOpercent_01~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
















# dual comparison: control vs all interventions. 1- ) FOR PRE-EXISTING DIFFERENCCE MODEERATORS ANALYSIS

table(d$manips_w1_C1vsC234)
d$manips_w1_C1vsC234[d$manips_w1_C1vsC234==0] <-3
d$manips_w1_C1vsC234[d$manips_w1_C1vsC234==1] <-5
table(d$manips_w1_C1vsC234)
# and create a EMC version using this and comparing against low vs. high
table(d$manips_W2_lowVshighQuality_numeric)

d$FOURMajorConditons<- d$manips_w1_C1vsC234 * d$manips_W2_lowVshighQuality_numeric
table(d$FOURMajorConditons)

d$FOURMajorConditons[d$FOURMajorConditons==30] <- "Control (W1) Seen Low Quality Poll (W2)"
d$FOURMajorConditons[d$FOURMajorConditons==50] <- "Interventions (W1) Seen Low Quality Poll (W2)"
d$FOURMajorConditons[d$FOURMajorConditons==300] <- "Control (W1) Seen High Quality Poll (W2)"
d$FOURMajorConditons[d$FOURMajorConditons==500] <- "Interventions (W1) Seen High Quality (W2)"
# alternative ordering of conditoions:
d$FOURMajorConditons <- factor(d$FOURMajorConditons, levels = c("Control (W1) Seen Low Quality Poll (W2)",
                                                                "Control (W1) Seen High Quality Poll (W2)",
                                                                "Interventions (W1) Seen Low Quality Poll (W2)",
                                                                "Interventions (W1) Seen High Quality (W2)"))
table(d$FOURMajorConditons)
is.factor(d$FOURMajorConditons)

# lets test in main model

r1 = lm(pollcred_DV_5~FOURMajorConditons
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
stargazer(r1, type = "text", out = "4WAY_baseline.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 

d$interactioncontrasts <- with(d, interaction(FOURMajorConditons, sep = "x"))
head(d$interactioncontrasts)
m1 = lm(pollcred_DV_5~interactioncontrasts+
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
cld(r1b)
plot_model(r1, type = "pred", terms = c("FOURMajorConditons"))
plot_model(r1, type = "pred", terms = c("FOURMajorConditons"),
           title = "Perceived Credibility of Polls by Conditions \n(Control vs. Interventions Combined)",
           axis.title = c("Control vs. Intervention Conditions","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Conditions (Control vs. Interventions Combined)", dodge = .3,
           colors=c("black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.3,.55) + coord_flip()









## and then test pre--existing diffs with this

r1 = lm(pollcred_DV_5~FOURMajorConditons*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r1)
plot_model(r1, type = "pred", terms = c("FOURMajorConditons","educat01"))
plot_model(r1, type = "pred", terms = c("educat01","FOURMajorConditons"))
plot_model(r1, type = "pred", terms = c("educat01","FOURMajorConditons"),
           title = "Figure 3A: Perceived Credibility of Polls by Conditions (Control vs. Interventions Combined)\nand Individuals' Education Levels",
           axis.title = c("Education Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Comparison Groups (Control vs. Interventions Combined)", dodge = .3,
           colors=c("lightblue", "darkgray", "blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.15,.7)



r2 = lm(pollcred_DV_5~FOURMajorConditons*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r2)
plot_model(r2, type = "pred", terms = c("FOURMajorConditons","esl_total01"))
plot_model(r2, type = "pred", terms = c("esl_total01","FOURMajorConditons"))
plot_model(r2, type = "pred", terms = c("esl_total01","FOURMajorConditons"),
           title = "Figure 3B: Perceived Credibility of Polls by Conditions (Control vs. Interventions Combined)\nand Individuals' Science Literacy Levels",
           axis.title = c("Science Literacy Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Comparison Groups (Control vs. Interventions Combined)", dodge = .3,
           colors=c("lightblue", "darkgray", "blue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.15,.7)


## combine interaction plots into PDF for edu and scilit
F3A<-plot_model(r1, type = "pred", terms = c("educat01","FOURMajorConditons"),
           title = "Figure 3A: Perceived Credibility of Polls by Conditions (Control vs. Interventions Combined)\nand Individuals' Education Levels",
           axis.title = c("Education Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Conditions (Control vs. Interventions Combined)", dodge = .3,
           colors=c("blue", "darkgray", "darkblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.15,.7)
F3A
F3B<-plot_model(r2, type = "pred", terms = c("esl_total01","FOURMajorConditons"),
           title = "Figure 3B: Perceived Credibility of Polls by Conditions (Control vs. Interventions Combined)\nand Individuals' Science Literacy Levels",
           axis.title = c("Science Literacy Levels","Perceived Credibility of Polls (W2)"),
           axis.labels = TRUE,   line.size = 1.5, 
           legend.title = "Conditions (Control vs. Interventions Combined)", dodge = .3,
           colors=c("blue", "darkgray", "darkblue", "black"), dot.size = 3) +
  theme(panel.grid.major = element_blank(), axis.line = element_line(colour = "black")) + theme_classic() +
  theme(legend.position = "right", legend.text = element_text(size = 13)) +
  theme(text = element_text(size = 13)) + ylim(0.15,.7)
F3B

pdf("Figure3AandB.pdf", width=10, height=12)
ggarrange(F3A, F3B,
          ncol = 1, nrow = 2)
dev.off()

#j

r3 = lm(pollcred_DV_5~FOURMajorConditons*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r3)
#plot_model(r3, type = "pred", terms = c("FOURMajorConditons","subjnum_W1"))
plot_model(r3, type = "pred", terms = c("subjnum_W1","FOURMajorConditons"))

r4 = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4)
#plot_model(r4, type = "pred", terms = c("FOURMajorConditons","RseenAttitudeInconsistentPO_vaxrisk_absolute"))
plot_model(r4, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","FOURMajorConditons"))

r5 = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5)
#plot_model(r5, type = "pred", terms = c("FOURMajorConditons","RseenAttitudeInconsistentPO_AIrisk_absolute"))
plot_model(r5, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","FOURMajorConditons"))

r6 = lm(pollcred_DV_5~FOURMajorConditons*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI, data=d) 
summary(r6) 
#plot_model(r6, type = "pred", terms = c("FOURMajorConditons","bias_POOLED"))
plot_model(r6, type = "pred", terms = c("bias_POOLED","FOURMajorConditons"))

stargazer(r1, r2, r3, r4, r5, r6, type = "text", out = "4WAY_Moderators.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 





## appendix for alternative AI unfavorable coding: NO DIFFERENCES AT ALL
# testing AI only
# RseenAttitudeInconsistentPO_aiPolicy_absolute
r5xx = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_aiPolicy_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5xx) # no differences at all
plot_model(r5xx, type = "pred", terms = c("RseenAttitudeInconsistentPO_aiPolicy_absolute","FOURMajorConditons"))
# create pooled bias using this AI variable version too:
# testing pooled version:
# combine these two
table(d$RseenAttitudeInconsistentPO_vaxrisk_absolute)
table(d$RseenAttitudeInconsistentPO_aiPolicy_absolute)
# AI bias
d$bias_AI_versionpolicy<-d$RseenAttitudeInconsistentPO_aiPolicy_absolute
d$bias_AI_versionpolicy[is.na(d$bias_AI_versionpolicy)] <- 0
table(d$bias_AI_versionpolicy)
#pooled
d$bias_POOLED_withAIpolicyversion <- d$bias_vax + d$bias_AI_versionpolicy
table(d$bias_POOLED_withAIpolicyversion)
r6xx = lm(pollcred_DV_5~FOURMajorConditons*bias_POOLED_withAIpolicyversion
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5xx) # no differences at all
plot_model(r6xx, type = "pred", terms = c("bias_POOLED_withAIpolicyversion","FOURMajorConditons"))

stargazer(r5xx, r6xx, type = "text", out = "4WAY_Moderators_AIUnforavorablealternativeCodingAIandPOOLEDupdated.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 






### appendix - split issue analysis for RQ3 unfavorable moderators

table(d$manips_W2_covid_ConcernVsConfident)
table(d$manips_W2_AIregulation_SupportVsOppose)

# covid
r4a = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_vaxrisk_absolute
       + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, 
       data=d[d$manips_W2_covid_ConcernVsConfident=="Concerned about Vaccine",]) 
summary(r4a)
plot_model(r4a, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","FOURMajorConditons"))

r4b = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_vaxrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, 
        data=d[d$manips_W2_covid_ConcernVsConfident=="Confident about Vaccine",]) 
summary(r4b)
plot_model(r4b, type = "pred", terms = c("RseenAttitudeInconsistentPO_vaxrisk_absolute","FOURMajorConditons"))

# ai
r5a = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, 
        data=d[d$manips_W2_AIregulation_SupportVsOppose=="Oppose AI-Regulation",]) 
summary(r5a)
plot_model(r5a, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","FOURMajorConditons"))

r5b = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_AIrisk_absolute
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, 
        data=d[d$manips_W2_AIregulation_SupportVsOppose=="Support AI-Regulation",]) 
summary(r5b)
plot_model(r5b, type = "pred", terms = c("RseenAttitudeInconsistentPO_AIrisk_absolute","FOURMajorConditons"))
# pooled - well, this test does not make sense for issue-pooled analysis


# alternative: 3way interaction instead of split analysis (BUT THIS DOES NOT MAKE MUCH SENSE SINCE THE INTERACTING ITEM AND WHAT IS IN UNFAVORABLE CODING IS SAME VARIABLE)

r4x = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_vaxrisk_absolute*manips_W2_covid_ConcernVsConfident
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r4x)

r5x = lm(pollcred_DV_5~FOURMajorConditons*RseenAttitudeInconsistentPO_AIrisk_absolute*manips_W2_AIregulation_SupportVsOppose
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d) 
summary(r5x)


stargazer(r4a, r4b, r5a, r5b, type = "text", out = "4WAY_Moderators_SplitSampleBasedOnResultDirectionality.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 

stargazer(r4x, r5x, type = "text", out = "4WAY_Moderators_3wayBasedOnResultDirectionality.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 







#### create appendix table for Rq1 and Rq2 (MODEL 1S ARE FOR RQ1, MODEL 2 IS JUST TO SEE THEM AS CONTROLS, MODEL 3S ARE FOR RQ2)
# vax
r1 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_vaxrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r1)
r2 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_vaxrisk_absolute+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r2)
r3 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_vaxrisk_absolute*manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r3)
stargazer(r1, r2, r3, type = "text", out = "unfavorable_Rq1andRq2tests_vax.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 
# ai
r4 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_AIrisk_absolute+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r4)
r5 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_AIrisk_absolute+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r5)
r6 = lm(pollcred_DV_5~RseenAttitudeInconsistentPO_AIrisk_absolute*manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r6)
stargazer(r4, r5, r6, type = "text", out = "unfavorable_Rq1andRq2tests_AI.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 
# pooled
r7 = lm(pollcred_DV_5~bias_POOLED+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r7)
r8 = lm(pollcred_DV_5~bias_POOLED+manips_W2_lowVshighQuality+manips_w1ff+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r8)
r9 = lm(pollcred_DV_5~bias_POOLED*manips_W2_lowVshighQuality+
          Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1, data=d)
summary(r9)
stargazer(r7, r8, r9, type = "text", out = "unfavorable_Rq1andRq2tests_pooled.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 










  
## Reviewer 2 appendix request for including all moderators as controls in moderator analysis:
r1 = lm(pollcred_DV_5~FOURMajorConditons*educat01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI+
          educat01+esl_total01+subjnum_W1+bias_POOLED, data=d) 
summary(r1)
r2 = lm(pollcred_DV_5~FOURMajorConditons*esl_total01
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI+
          educat01+esl_total01+subjnum_W1+bias_POOLED, data=d) 
summary(r2)
r3 = lm(pollcred_DV_5~FOURMajorConditons*subjnum_W1
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI+
          educat01+esl_total01+subjnum_W1+bias_POOLED, data=d) 
summary(r3)
r6 = lm(pollcred_DV_5~FOURMajorConditons*bias_POOLED
        + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI+
          educat01+esl_total01+subjnum_W1+bias_POOLED, data=d) 
summary(r6) 

stargazer(r1, r2, r3, r6, type = "text", out = "4WAY_Moderators_AppendixForAllModeratorsAsControls.html" ,title = "DV", digits = 3, 
          star.cutoffs = c(0.05, 0.01, 0.001),report = ("vc*sp")) 













##### HOW LONG DID EACH INTERVENTION TAKE?

# list of all timer variables= duratin to page submit - add these across conditions and compare condition lenghts:
# CONTROL
d$c1_timer1 <- d$timer8_Page_Submit
d$c1_timer2 <- d$timer9_Page_Submit
d$c1_timer3 <- d$timer10_Page_Submit
d$c1_timer4 <- d$timer11_Page_Submit
d$c1_timer5 <- d$Q564_Page_Submit
d$c1_timer6 <- d$Q565_Page_Submit
d$c1_timer7 <- d$timer12_Page_Submit
# PASSIVE
d$c2_timer1<-d$timer13_Page_Submit
d$c2_timer2<-d$timer14_Page_Submit
d$c2_timer3<-d$timer15_Page_Submit
d$c2_timer4<-d$timer16_Page_Submit
d$c2_timer5<-d$timer17_Page_Submit
d$c2_timer6<-d$timer18_Page_Submit
d$c2_timer7<-d$Q474_Page_Submit
# ACTIVE
d$c3_timer1<-d$Q381_Page_Submit
d$c3_timer2<-d$Q383_Page_Submit
d$c3_timer3<-d$Q385_Page_Submit
d$c3_timer4<-d$Q387_Page_Submit
d$c3_timer5<-d$Q389_Page_Submit
d$c3_timer6<-d$Q381_Page_Submit
d$c3_timer7<-d$Q476_Page_Submit
d$c3_timer8<-d$Q402_Page_Submit
d$c3_timer9<-d$Q404_Page_Submit
d$c3_timer10<-d$Q406_Page_Submit
# INOCULATION
d$c4_timer1<-d$Q409_Page_Submit
d$c4_timer2<-d$Q411_Page_Submit
d$c4_timer3<-d$Q413_Page_Submit
d$c4_timer4<-d$Q415_Page_Submit
d$c4_timer5<-d$Q417_Page_Submit
d$c4_timer6<-d$Q419_Page_Submit
d$c4_timer7<-d$Q479_Page_Submit
d$c4_timer8<-d$Q426_Page_Submit
d$c4_timer9<-d$Q430_Page_Submit
d$c4_timer10<-d$Q434_Page_Submit
d$c4_timer11<-d$Q436_Page_Submit
d$c4_timer12<-d$Q604_Page_Submit
d$c4_timer13<-d$Q603_Page_Submit
d$c4_timer14<-d$Q602_Page_Submit
d$c4_timer15<-d$Q601_Page_Submit



# CONTROL
d$c1_timer1[is.na(d$c1_timer1)] <- 0
d$c1_timer2[is.na(d$c1_timer2)] <- 0
d$c1_timer3[is.na(d$c1_timer3)] <- 0
d$c1_timer4[is.na(d$c1_timer4)] <- 0
d$c1_timer5[is.na(d$c1_timer5)] <- 0
d$c1_timer6[is.na(d$c1_timer6)] <- 0
d$c1_timer7[is.na(d$c1_timer7)] <- 0

d$c1_time_combined <- (d$c1_timer1 + d$c1_timer2 + d$c1_timer3 +d$c1_timer4 +
  d$c1_timer5 + d$c1_timer6 + d$c1_timer7)
describe(d$c1_time_combined)
table(d$c1_time_combined)

# PASSIVE
d$c2_timer1[is.na(d$c2_timer1)] <- 0
d$c2_timer2[is.na(d$c2_timer2)] <- 0
d$c2_timer3[is.na(d$c2_timer3)] <- 0
d$c2_timer4[is.na(d$c2_timer4)] <- 0
d$c2_timer5[is.na(d$c2_timer5)] <- 0
d$c2_timer6[is.na(d$c2_timer6)] <- 0
d$c2_timer7[is.na(d$c2_timer7)] <- 0

d$c2_time_combined <- (d$c2_timer1 + d$c2_timer2 + d$c2_timer3 +d$c2_timer4 +
                         d$c2_timer5 + d$c2_timer6 + d$c2_timer7)
describe(d$c2_time_combined)
table(d$c2_time_combined)

# ACTIVE

d$c3_timer1[is.na(d$c3_timer1)] <- 0
d$c3_timer2[is.na(d$c3_timer2)] <- 0
d$c3_timer3[is.na(d$c3_timer3)] <- 0
d$c3_timer4[is.na(d$c3_timer4)] <- 0
d$c3_timer5[is.na(d$c3_timer5)] <- 0
d$c3_timer6[is.na(d$c3_timer6)] <- 0
d$c3_timer7[is.na(d$c3_timer7)] <- 0
d$c3_timer8[is.na(d$c3_timer8)] <- 0
d$c3_timer9[is.na(d$c3_timer9)] <- 0
d$c3_timer10[is.na(d$c3_timer10)] <- 0

d$c3_time_combined <- (d$c3_timer1 + d$c3_timer2 + d$c3_timer3 +d$c3_timer4 +
                         d$c3_timer5 + d$c3_timer6 + d$c3_timer7 + 
                         d$c3_timer8 + d$c3_timer9 + d$c3_timer10)
describe(d$c3_time_combined)
table(d$c3_time_combined)

# INOCU
d$c4_timer1[is.na(d$c4_timer1)] <- 0
d$c4_timer2[is.na(d$c4_timer2)] <- 0
d$c4_timer3[is.na(d$c4_timer3)] <- 0
d$c4_timer4[is.na(d$c4_timer4)] <- 0
d$c4_timer5[is.na(d$c4_timer5)] <- 0
d$c4_timer6[is.na(d$c4_timer6)] <- 0
d$c4_timer7[is.na(d$c4_timer7)] <- 0
d$c4_timer8[is.na(d$c4_timer8)] <- 0
d$c4_timer9[is.na(d$c4_timer9)] <- 0
d$c4_timer10[is.na(d$c4_timer10)] <- 0
d$c4_timer11[is.na(d$c4_timer11)] <- 0
d$c4_timer12[is.na(d$c4_timer12)] <- 0
d$c4_timer13[is.na(d$c4_timer13)] <- 0
d$c4_timer14[is.na(d$c4_timer14)] <- 0
d$c4_timer15[is.na(d$c4_timer15)] <- 0

d$c4_time_combined <- (d$c4_timer1 + d$c4_timer2 + d$c4_timer3 +d$c4_timer4 +
                         d$c4_timer5 + d$c4_timer6 + d$c4_timer7 + 
                         d$c4_timer8 + d$c4_timer9 + d$c4_timer10 +
                         d$c4_timer11 + d$c4_timer12 + d$c4_timer13 +
                         d$c4_timer14 + d$c4_timer15)
describe(d$c4_time_combined)
table(d$c4_time_combined)


d$combined_W1_conditionTIMEs <- (d$c1_time_combined + d$c2_time_combined +
                                   d$c3_time_combined + d$c4_time_combined)

table(d$combined_W1_conditionTIMEs)
summary(d$combined_W1_conditionTIMEs)
describe(d$combined_W1_conditionTIMEs)

timingmodel <- aov(d$combined_W1_conditionTIMEs~d$manips_w1ff)
summary(timingmodel)
TukeyHSD(timingmodel)

timingmodel <- lm(combined_W1_conditionTIMEs~manips_w1ff, d)
summary(timingmodel)
stargazer(timingmodel, type = "text", out = "W1LenghtTimingModel.html" ,title = "DV", digits = 2, star.cutoffs = c(0.05, 0.01, 0.001))

d$interactioncontrasts <- with(d, interaction(manips_w1ff, sep = "x"))
m1 = lm(combined_W1_conditionTIMEs~interactioncontrasts, data=d) 
r1b <- glht(m1, linfct = mcp(interactioncontrasts = "Tukey"))
summary(r1b)
plot_model(timingmodel, type = "pred", terms = c("manips_w1ff"))

st(d, vars = c('combined_W1_conditionTIMEs'), 
   group = 'manips_w1ff', 
   group.test = TRUE, 
   file='checks of W1 manips at W2')

st(d, vars = c('combined_W1_conditionTIMEs'),   
   add.median = TRUE, 
   factor.percent = TRUE, 
   factor.counts = TRUE,
   group = 'manips_w1ff', 
   group.test = TRUE, 
   file='descriptives_timing')



# how about we add W1-duration as a control in main models: combined_W1_conditionTIMEs


r1 = lm(pollcred_DV_5~manips_W2_lowVshighQuality*manips_w1ff
          + Age_Years + Chinese01 + Indian + pretest_INDEX_pollInterest_W1+manips_W2_covidVsAI+combined_W1_conditionTIMEs, data=d) 
summary(r1)


#### IN-BUILT QUIZ PERFORMANCE DURING MANIPULATIONS AS A MODERATOR?
# well this doesnt make much sense..







